| Name | Message | Date |
|---|---|---|
| 📄 FromShould.cs | 1 day ago | |
| 📄 ParseShould.cs | 1 day ago |
📄
test/JsonLdRecipeParser.Tests/RecipeTests/ParseShould.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
using System; using System.Text.Json; using Microsoft.VisualStudio.TestTools.UnitTesting; using Shouldly; namespace JsonLdRecipeParser.Tests.RecipeTests; [TestClass] public class ParseShould { [TestMethod] public void ParseJsonLdFromGoogleExample() { // Arrange var document = JsonSerializer.Deserialize<JsonDocument>(TestData.GoogleExample)!; // Act var result = Recipe.Parse(document); // Assert result.ShouldBeEquivalentTo(expectedGoogleExampleRecipe); } [TestMethod] public void ParseJsonLdFromGoogleExampleInArray() { // Arrange var document = JsonSerializer.Deserialize<JsonDocument>($"[{TestData.GoogleExample}]")!; // Act var result = Recipe.Parse(document); // Assert result.ShouldBeEquivalentTo(expectedGoogleExampleRecipe); } private static readonly Recipe expectedGoogleExampleRecipe = new() { Name = "Non-Alcoholic Piña Colada", Description = "This non-alcoholic pina colada is everyone's favorite!", Authors = [new Author { Name = "Mary Stone" }], PrepTime = TimeSpan.FromMinutes(1), TotalTime = TimeSpan.FromMinutes(3), CookTime = TimeSpan.FromMinutes(2), Nutrients = new Nutrients { Calories = new Amount { Value = new ExactAmountValue(120.0d), Unit = "calories" }, }, Category = ["Drink"], Cuisine = ["American"], Ingredients = [ new Ingredient { Name = "of", Amount = new Amount { Value = new ExactAmountValue(400.0d), Unit = "ml" }, }, new Ingredient { Name = "cream", Amount = new Amount { Value = new ExactAmountValue(100.0d), Unit = "ml" }, }, new Ingredient { Name = "ice" }, ], InstructionSections = [ new InstructionSection { Instructions = [ new Instruction { Name = "Blend", Text = "Blend 400ml of pineapple juice and 100ml cream of coconut until smooth.", }, ], }, new InstructionSection { Instructions = [new Instruction { Name = "Fill", Text = "Fill a glass with ice." }], }, new InstructionSection { Instructions = [ new Instruction { Name = "Pour", Text = "Pour the pineapple juice and coconut mixture over ice." }, ], }, ], Yield = new Amount { Value = new ExactAmountValue(4.0d), Unit = "servings" }, }; }