Skip to content

Commit 2ffc87a

Browse files
authored
Merge pull request #107 from lk-code/FDB-106
Fdb 106
2 parents f2b76c9 + 2d5c3ec commit 2ffc87a

20 files changed

Lines changed: 325 additions & 279 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Lars Krämer
3+
Copyright (c) 2025 Lars Krämer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FluentDataBuilder
22

3-
![html-compiler-tool](https://raw.githubusercontent.com/lk-code/fluent-data-builder/main/icon_128.png)
3+
![fluent-data-builder](https://raw.githubusercontent.com/lk-code/fluent-data-builder/main/icon_128.png)
44

55
[![License](https://img.shields.io/github/license/lk-code/fluent-data-builder.svg?style=flat-square)](https://github.com/lk-code/fluent-data-builder/blob/master/LICENSE)
66
[![Downloads](https://img.shields.io/nuget/dt/FluentDataBuilder.svg?style=flat-square)](https://www.nuget.org/packages/FluentDataBuilder/)

source/FluentDataBuilder.ExtensionTests/FluentDataBuilder.ExtensionTests.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="FluentAssertions" Version="6.12.1" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
14-
<PackageReference Include="MSTest.TestAdapter" Version="3.7.3" />
15-
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
13+
<PackageReference Include="MSTest.TestAdapter" Version="3.8.3" />
14+
<PackageReference Include="MSTest.TestFramework" Version="3.8.3" />
1615
<PackageReference Include="coverlet.collector" Version="6.0.4">
1716
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1817
<PrivateAssets>all</PrivateAssets>
1918
</PackageReference>
19+
<PackageReference Include="Shouldly" Version="4.3.0" />
2020
</ItemGroup>
2121

2222
<ItemGroup>
2323
<ProjectReference Include="..\FluentDataBuilder.Json\FluentDataBuilder.Json.csproj"/>
2424
<ProjectReference Include="..\FluentDataBuilder.NewtonsoftJson\FluentDataBuilder.NewtonsoftJson.csproj"/>
25+
<ProjectReference Include="..\FluentDataBuilder.TestsShared\FluentDataBuilder.TestsShared.csproj" />
2526
<ProjectReference Include="..\FluentDataBuilder.Xml\FluentDataBuilder.Xml.csproj"/>
2627
<ProjectReference Include="..\FluentDataBuilder.Yaml\FluentDataBuilder.Yaml.csproj" />
2728
</ItemGroup>

source/FluentDataBuilder.ExtensionTests/Json/BuildTests.cs

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Text.Json;
2-
using FluentAssertions;
2+
using Shouldly;
33
using FluentDataBuilder.Json;
4+
using FluentDataBuilder.TestsShared.Extensions;
45

56
namespace FluentDataBuilder.ExtensionTests.Json;
67

@@ -23,8 +24,8 @@ public void Build_WithChildObject_Returns()
2324

2425
string result = jsonResult.RootElement.GetRawText();
2526

26-
result.Should().NotBeNullOrEmpty();
27-
result.Should().Be("{\"id\":\"7c27a562-d405-4b22-9ade-37503bed6014\",\"name\":\"John Doe\",\"editor\":{\"typevalue\":\"a object\",\"numbervalue\":55865,\"booleanvalue\":true}}");
27+
result.ShouldNotBeNullOrEmpty();
28+
result.ShouldBe("{\"id\":\"7c27a562-d405-4b22-9ade-37503bed6014\",\"name\":\"John Doe\",\"editor\":{\"typevalue\":\"a object\",\"numbervalue\":55865,\"booleanvalue\":true}}");
2829
}
2930

3031
[TestMethod]
@@ -39,8 +40,8 @@ public void Build_WithSimpleObject_Returns()
3940

4041
string result = jsonResult.RootElement.GetRawText();
4142

42-
result.Should().NotBeNullOrEmpty();
43-
result.Should().Be("{\"name\":\"this is a test\",\"number\":123}");
43+
result.ShouldNotBeNullOrEmpty();
44+
result.ShouldBe("{\"name\":\"this is a test\",\"number\":123}");
4445
}
4546

4647
[TestMethod]
@@ -55,8 +56,8 @@ public void Build_WithStringList_Returns()
5556

5657
string result = jsonResult.RootElement.GetRawText();
5758

58-
result.Should().NotBeNullOrEmpty();
59-
result.Should().Be("{\"name\":\"this is a test\",\"array\":[\"this\",\"is\",\"a\",\"test\"]}");
59+
result.ShouldNotBeNullOrEmpty();
60+
result.ShouldBe("{\"name\":\"this is a test\",\"array\":[\"this\",\"is\",\"a\",\"test\"]}");
6061
}
6162

6263
[TestMethod]
@@ -71,8 +72,8 @@ public void Build_WithStringArray_Returns()
7172

7273
string result = jsonResult.RootElement.GetRawText();
7374

74-
result.Should().NotBeNullOrEmpty();
75-
result.Should().Be("{\"name\":\"this is a test\",\"array\":[\"this\",\"is\",\"a\",\"test\"]}");
75+
result.ShouldNotBeNullOrEmpty();
76+
result.ShouldBe("{\"name\":\"this is a test\",\"array\":[\"this\",\"is\",\"a\",\"test\"]}");
7677
}
7778

7879
[TestMethod]
@@ -87,8 +88,8 @@ public void Build_WithMixedArray_Returns()
8788

8889
string result = jsonResult.RootElement.GetRawText();
8990

90-
result.Should().NotBeNullOrEmpty();
91-
result.Should().Be("{\"name\":\"this is a test\",\"array\":[\"this\",123,true,456.78]}");
91+
result.ShouldNotBeNullOrEmpty();
92+
result.ShouldBe("{\"name\":\"this is a test\",\"array\":[\"this\",123,true,456.78]}");
9293
}
9394

9495
[TestMethod]
@@ -103,8 +104,8 @@ public void Build_WithNumericIntArray_Returns()
103104

104105
string result = jsonResult.RootElement.GetRawText();
105106

106-
result.Should().NotBeNullOrEmpty();
107-
result.Should().Be("{\"name\":\"this is a test\",\"array\":[12,34,56,78]}");
107+
result.ShouldNotBeNullOrEmpty();
108+
result.ShouldBe("{\"name\":\"this is a test\",\"array\":[12,34,56,78]}");
108109
}
109110

110111
[TestMethod]
@@ -119,8 +120,8 @@ public void Build_WithNumericDoubleArray_Returns()
119120

120121
string result = jsonResult.RootElement.GetRawText();
121122

122-
result.Should().NotBeNullOrEmpty();
123-
result.Should().Be("{\"name\":\"this is a test\",\"array\":[12.34,34,56.78,78.901]}");
123+
result.ShouldNotBeNullOrEmpty();
124+
result.ShouldBe("{\"name\":\"this is a test\",\"array\":[12.34,34,56.78,78.901]}");
124125
}
125126

126127
[TestMethod]
@@ -147,8 +148,8 @@ public void Build_WithArrayWithAllDataTypes_Returns()
147148

148149
string result = jsonResult.RootElement.GetRawText();
149150

150-
result.Should().NotBeNullOrEmpty();
151-
result.Should().Be("{\"name\":\"this is a test\",\"array\":[15,15.123412341234,16.123413,false,9.123412341234,\"test\",\"x\",9876,9876]}");
151+
result.ShouldNotBeNullOrEmpty();
152+
result.ShouldBe("{\"name\":\"this is a test\",\"array\":[15,15.123412341234,16.123413,false,9.123412341234,\"test\",\"x\",9876,9876]}");
152153
}
153154

154155
[TestMethod]
@@ -157,8 +158,8 @@ public void LoadFrom_WithJsonDocumentNull_Returns()
157158
JsonDocument? json = null;
158159
IDataBuilder builder = new DataBuilder().LoadFrom(json!);
159160

160-
builder.Should().NotBeNull();
161-
builder.GetProperties().Count.Should().Be(0);
161+
builder.ShouldNotBeNull();
162+
builder.GetProperties().Count.ShouldBe(0);
162163
}
163164

164165
[TestMethod]
@@ -196,25 +197,25 @@ public void LoadFrom_WithSimpleJson_Returns()
196197

197198
IDataBuilder builder = new DataBuilder().LoadFrom(json);
198199

199-
builder.Should().NotBeNull();
200+
builder.ShouldNotBeNull();
200201
var properties = builder.GetProperties();
201-
properties.Count.Should().Be(7);
202-
properties["name"].Should().Be("this is a test");
203-
properties["number"].Should().Be(123);
204-
properties["decimal"].Should().Be(123.45);
205-
properties["boolean"].Should().Be(true);
206-
properties["null"].Should().BeNull();
207-
properties["array"].Should().BeOfType<object[]>();
208-
properties["array"].Should().BeEquivalentTo(new List<string> { "this", "is", "a", "test" });
209-
properties["object"].Should().BeOfType<Dictionary<string, object>>();
210-
properties["object"].Should().BeEquivalentTo(new Dictionary<string, object>
202+
properties.Count.ShouldBe(7);
203+
properties["name"].ShouldBe("this is a test");
204+
properties["number"].ShouldBe(123);
205+
properties["decimal"].ShouldBe(123.45);
206+
properties["boolean"].ShouldBe(true);
207+
properties["null"].ShouldBeNull();
208+
properties["array"].ShouldBeOfType<object[]>();
209+
properties["array"].ShouldBeEquivalentTo(new object[] { "this", "is", "a", "test" });
210+
properties["object"].ShouldBeEqualTo<Dictionary<string, object>>(dict =>
211211
{
212-
{ "name", "this is a test" },
213-
{ "number", 123 },
214-
{ "decimal", 123.45 },
215-
{ "boolean", true },
216-
{ "null", null! },
217-
{ "array", new List<string> { "this", "is", "a", "test" } }
212+
dict.Count.ShouldBe(6);
213+
dict.ShouldContain("name", "this is a test");
214+
dict.ShouldContain("number", 123);
215+
dict.ShouldContain("decimal", 123.45);
216+
dict.ShouldContain("boolean", true);
217+
dict.ShouldContain("null", null!);
218+
dict.ShouldContain("array", new object[] { "this", "is", "a", "test" });
218219
});
219220
}
220221

@@ -224,8 +225,8 @@ public void LoadFrom_WithStringNull_Returns()
224225
string? json = null;
225226
IDataBuilder builder = new DataBuilder().LoadFrom(json!);
226227

227-
builder.Should().NotBeNull();
228-
builder.GetProperties().Count.Should().Be(0);
228+
builder.ShouldNotBeNull();
229+
builder.GetProperties().Count.ShouldBe(0);
229230
}
230231

231232
[TestMethod]
@@ -262,25 +263,25 @@ public void LoadFrom_WithSimpleJsonString_Returns()
262263
}
263264
""");
264265

265-
builder.Should().NotBeNull();
266+
builder.ShouldNotBeNull();
266267
var properties = builder.GetProperties();
267-
properties.Count.Should().Be(7);
268-
properties["name"].Should().Be("this is a test");
269-
properties["number"].Should().Be(123);
270-
properties["decimal"].Should().Be(123.45);
271-
properties["boolean"].Should().Be(true);
272-
properties["null"].Should().BeNull();
273-
properties["array"].Should().BeOfType<object[]>();
274-
properties["array"].Should().BeEquivalentTo(new List<string> { "this", "is", "a", "test" });
275-
properties["object"].Should().BeOfType<Dictionary<string, object>>();
276-
properties["object"].Should().BeEquivalentTo(new Dictionary<string, object>
268+
properties.Count.ShouldBe(7);
269+
properties["name"].ShouldBe("this is a test");
270+
properties["number"].ShouldBe(123);
271+
properties["decimal"].ShouldBe(123.45);
272+
properties["boolean"].ShouldBe(true);
273+
properties["null"].ShouldBeNull();
274+
properties["array"].ShouldBeOfType<object[]>();
275+
properties["array"].ShouldBeEquivalentTo(new object[] { "this", "is", "a", "test" });
276+
properties["object"].ShouldBeEqualTo<Dictionary<string, object>>(dict =>
277277
{
278-
{ "name", "this is a test" },
279-
{ "number", 123 },
280-
{ "decimal", 123.45 },
281-
{ "boolean", true },
282-
{ "null", null! },
283-
{ "array", new List<string> { "this", "is", "a", "test" } }
278+
dict.Count.ShouldBe(6);
279+
dict.ShouldContain("name", "this is a test");
280+
dict.ShouldContain("number", 123);
281+
dict.ShouldContain("decimal", 123.45);
282+
dict.ShouldContain("boolean", true);
283+
dict.ShouldContain("null", null!);
284+
dict.ShouldContain("array", new object[] { "this", "is", "a", "test" });
284285
});
285286
}
286287

@@ -308,29 +309,29 @@ public void LoadFrom_WithSpecificDataObjectFromString_Returns()
308309
}
309310
""");
310311

311-
builder.Should().NotBeNull();
312+
builder.ShouldNotBeNull();
312313
var properties = builder.GetProperties();
313-
properties.Count.Should().Be(3);
314-
properties["Title"].Should().Be("Section Page");
315-
properties["Website"].Should().BeOfType<Dictionary<string, object>>();
316-
properties["Website"].Should().BeEquivalentTo(new Dictionary<string, object>
314+
properties.Count.ShouldBe(3);
315+
properties["Title"].ShouldBe("Section Page");
316+
properties["Website"].ShouldBeOfType<Dictionary<string, object>>();
317+
properties["Website"].ShouldBeEquivalentTo(new Dictionary<string, object>
317318
{
318319
{ "Author", "htmlc" }
319320
});
320-
properties["Names"].Should().BeOfType<object[]>();
321+
properties["Names"].ShouldBeOfType<object[]>();
321322
object[] objArray = (properties["Names"] as object[])!;
322-
objArray[0].Should().BeOfType<Dictionary<string, object>>();
323-
objArray[0].Should().BeEquivalentTo(new Dictionary<string, object>
323+
objArray[0].ShouldBeOfType<Dictionary<string, object>>();
324+
objArray[0].ShouldBeEquivalentTo(new Dictionary<string, object>
324325
{
325326
{ "Name", "Max" }
326327
});
327-
objArray[1].Should().BeOfType<Dictionary<string, object>>();
328-
objArray[1].Should().BeEquivalentTo(new Dictionary<string, object>
328+
objArray[1].ShouldBeOfType<Dictionary<string, object>>();
329+
objArray[1].ShouldBeEquivalentTo(new Dictionary<string, object>
329330
{
330331
{ "Name", "Lisa" }
331332
});
332-
objArray[2].Should().BeOfType<Dictionary<string, object>>();
333-
objArray[2].Should().BeEquivalentTo(new Dictionary<string, object>
333+
objArray[2].ShouldBeOfType<Dictionary<string, object>>();
334+
objArray[2].ShouldBeEquivalentTo(new Dictionary<string, object>
334335
{
335336
{ "Name", "Fred" }
336337
});

0 commit comments

Comments
 (0)