| Name | Message | Date |
|---|---|---|
| 📄 FromShould.cs | 1 day ago | |
| 📄 TryParseShould.cs | 3 days ago |
📄
test/JsonLdRecipeParser.Tests/AmountTests/FromShould.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using JsonLdRecipeParser.Json; using Microsoft.VisualStudio.TestTools.UnitTesting; using Shouldly; namespace JsonLdRecipeParser.Tests.AmountTests; [TestClass] public class FromShould { [TestMethod] public void MapAStringQuantity() { // Arrange var quantity = new Quantity { Value = "4 servings" }; // Act var result = Amount.From(quantity); // Assert result.ShouldBeEquivalentTo(new Amount { Value = new ExactAmountValue(4.0d), Unit = "servings" }); } [TestMethod] public void MapAQuantitativeValueWithDoubleValue() { // Arrange var quantity = new Quantity { Value = new QuantitativeValue { Value = new ValueProperty { Value = 400.0d } } }; // Act var result = Amount.From(quantity); // Assert result.ShouldBeEquivalentTo(new Amount { Value = new ExactAmountValue(400.0d), Unit = null }); } [TestMethod] public void MapAQuantitativeValueWithStringValue() { // Arrange var quantity = new Quantity { Value = new QuantitativeValue { Value = new ValueProperty { Value = "2.5" } } }; // Act var result = Amount.From(quantity); // Assert result.ShouldBeEquivalentTo(new Amount { Value = new ExactAmountValue(2.5d), Unit = null }); } [TestMethod] public void MapAQuantitativeValueWithUnitText() { // Arrange var quantity = new Quantity { Value = new QuantitativeValue { Value = new ValueProperty { Value = 400.0d }, UnitText = "ml", }, }; // Act var result = Amount.From(quantity); // Assert result.ShouldBeEquivalentTo(new Amount { Value = new ExactAmountValue(400.0d), Unit = "ml" }); } [TestMethod] public void MapAQuantitativeValueWithUnitCodeWhenUnitTextIsMissing() { // Arrange var quantity = new Quantity { Value = new QuantitativeValue { Value = new ValueProperty { Value = 250.0d }, UnitCode = "GRM", }, }; // Act var result = Amount.From(quantity); // Assert result.ShouldBeEquivalentTo(new Amount { Value = new ExactAmountValue(250.0d), Unit = "GRM" }); } [TestMethod] public void PreferUnitTextOverUnitCode() { // Arrange var quantity = new Quantity { Value = new QuantitativeValue { Value = new ValueProperty { Value = 10.0d }, UnitText = "dl", UnitCode = "DLT", }, }; // Act var result = Amount.From(quantity); // Assert result.ShouldBeEquivalentTo(new Amount { Value = new ExactAmountValue(10.0d), Unit = "dl" }); } }