| Name | Message | Date |
|---|---|---|
| 📄 FromShould.cs | 1 day ago |
📄
test/JsonLdRecipeParser.Tests/NutrientsTests/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.NutrientsTests; [TestClass] public class FromShould { [TestMethod] public void MapStringQuantities() { // Arrange var nutrition = new NutritionInformation { Calories = new Quantity { Value = "120 calories" }, CarbohydrateContent = new Quantity { Value = "10 g" }, CholesterolContent = new Quantity { Value = "0 mg" }, FatContent = new Quantity { Value = "5 g" }, FiberContent = new Quantity { Value = "2 g" }, ProteinContent = new Quantity { Value = "3 g" }, SaturatedFatContent = new Quantity { Value = "1 g" }, ServingSize = new Quantity { Value = "1 cup" }, SodiumContent = new Quantity { Value = "200 mg" }, SugarContent = new Quantity { Value = "4 g" }, TransFatContent = new Quantity { Value = "0 g" }, UnsaturatedFatContent = new Quantity { Value = "4 g" }, }; // Act var result = Nutrients.From(nutrition); // Assert result.ShouldBeEquivalentTo( new Nutrients { Calories = new Amount { Value = new ExactAmountValue(120.0d), Unit = "calories" }, Carbohydrate = new Amount { Value = new ExactAmountValue(10.0d), Unit = "g" }, Cholesterol = new Amount { Value = new ExactAmountValue(0.0d), Unit = "mg" }, Fat = new Amount { Value = new ExactAmountValue(5.0d), Unit = "g" }, Fiber = new Amount { Value = new ExactAmountValue(2.0d), Unit = "g" }, Protein = new Amount { Value = new ExactAmountValue(3.0d), Unit = "g" }, SaturatedFat = new Amount { Value = new ExactAmountValue(1.0d), Unit = "g" }, ServingSize = new Amount { Value = new ExactAmountValue(1.0d), Unit = "cup" }, Sodium = new Amount { Value = new ExactAmountValue(200.0d), Unit = "mg" }, Sugar = new Amount { Value = new ExactAmountValue(4.0d), Unit = "g" }, TransFat = new Amount { Value = new ExactAmountValue(0.0d), Unit = "g" }, UnsaturatedFat = new Amount { Value = new ExactAmountValue(4.0d), Unit = "g" }, } ); } [TestMethod] public void MapQuantitativeValueQuantities() { // Arrange var nutrition = new NutritionInformation { Calories = new Quantity { Value = new QuantitativeValue { Value = new ValueProperty { Value = 120.0d }, UnitText = "calories", }, }, }; // Act var result = Nutrients.From(nutrition); // Assert result.ShouldBeEquivalentTo( new Nutrients { Calories = new Amount { Value = new ExactAmountValue(120.0d), Unit = "calories" }, } ); } [TestMethod] public void MapNullNutrientFields() { // Arrange var nutrition = new NutritionInformation { Calories = new Quantity { Value = "120 calories" } }; // Act var result = Nutrients.From(nutrition); // Assert result.ShouldBeEquivalentTo( new Nutrients { Calories = new Amount { Value = new ExactAmountValue(120.0d), Unit = "calories" }, } ); result.Carbohydrate.ShouldBeNull(); result.Cholesterol.ShouldBeNull(); result.Fat.ShouldBeNull(); result.Fiber.ShouldBeNull(); result.Protein.ShouldBeNull(); result.SaturatedFat.ShouldBeNull(); result.ServingSize.ShouldBeNull(); result.Sodium.ShouldBeNull(); result.Sugar.ShouldBeNull(); result.TransFat.ShouldBeNull(); result.UnsaturatedFat.ShouldBeNull(); } }