Skip to content

Commit a144b88

Browse files
committed
Switch from asserts to Shouldly
1 parent 2cb17b4 commit a144b88

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

SQLiteSharp.Tests/NullableTest.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ public void Test1() {
1818

1919
// Find one item in the table matching a predicate
2020
NullableItem Item = NullableItems.FindAll().First();
21-
Assert.Null(Item.NullableIntWithNullValue);
22-
Assert.Equal(3, Item.NullableIntWithNonNullValue);
23-
Assert.Equal(4, Item.NonNullableInt);
21+
Item.NullableIntWithNullValue.ShouldBeNull();
22+
Item.NullableIntWithNonNullValue.ShouldBe(3);
23+
Item.NonNullableInt.ShouldBe(4);
2424
}
2525
[Fact]
2626
public void TestSqliteValue() {
2727
// Test nullable integer with non-null value
2828
SqliteValue NullableIntWithNullValue = (long?)null;
29-
Assert.Throws<NullReferenceException>(() => NullableIntWithNullValue.CastInteger);
30-
Assert.Null(NullableIntWithNullValue.AsInteger);
31-
Assert.True(NullableIntWithNullValue.IsNull);
29+
Should.Throw<NullReferenceException>(() => NullableIntWithNullValue.CastInteger);
30+
NullableIntWithNullValue.AsInteger.ShouldBeNull();
31+
NullableIntWithNullValue.IsNull.ShouldBeTrue();
3232

3333
// Test nullable integer with non-null value
3434
SqliteValue NullableIntWithNonNullValue = (long?)3;
35-
Assert.Equal(3, NullableIntWithNonNullValue.CastInteger);
36-
Assert.Equal(3, NullableIntWithNonNullValue.AsInteger);
37-
Assert.False(NullableIntWithNonNullValue.IsNull);
35+
NullableIntWithNonNullValue.CastInteger.ShouldBe(3);
36+
NullableIntWithNonNullValue.AsInteger.ShouldBe(3);
37+
NullableIntWithNonNullValue.IsNull.ShouldBe(false);
3838

3939
// Test non-nullable integer
4040
SqliteValue NonNullableInt = (long)4;
41-
Assert.Equal(4, NonNullableInt.CastInteger);
42-
Assert.Equal(4, NonNullableInt.AsInteger);
43-
Assert.False(NonNullableInt.IsNull);
41+
NonNullableInt.CastInteger.ShouldBe(4);
42+
NonNullableInt.AsInteger.ShouldBe(4);
43+
NonNullableInt.IsNull.ShouldBe(false);
4444
}
4545
}
4646

SQLiteSharp.Tests/OperatorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public void Test1() {
1717

1818
// Find one item in the table matching a predicate
1919
ShopItem? Item = ShopItems.FindOne(ShopItem => ShopItem.Count == (ShopItem.Count * 2 - ShopItem.Count));
20-
Assert.NotNull(Item);
20+
Item.ShouldNotBeNull();
2121

2222
// Find one item in the table matching a predicate with method calls
2323
ShopItem? Item2 = ShopItems.FindOne(ShopItem => !string.IsNullOrEmpty(ShopItem.ItemName) && ShopItem.ItemName.Replace("dragon", "drag") == "dragfruit");
24-
Assert.NotNull(Item2);
24+
Item2.ShouldNotBeNull();
2525

2626
ShopItem? Item3 = ShopItems.FindOne(ShopItem => int.Parse(ShopItem.Count.ToString()).Equals(1));
2727
}

SQLiteSharp.Tests/ReadMeTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ public void Test1() {
2626

2727
// Find one item in the table matching a predicate
2828
ShopItem? Apple = ShopItems.FindOne(ShopItem => ShopItem.ItemName == "Apple");
29-
Assert.NotNull(Apple);
29+
Apple.ShouldNotBeNull();
3030

3131
// Delete an item from the table
3232
ShopItems.DeleteByKey(Apple.Id);
3333

3434
// Find several items in the table
3535
List<ShopItem> Bananas = ShopItems.Find(ShopItem => ShopItem.ItemName == "Banana").ToList();
36-
Assert.Single(Bananas);
36+
Bananas.ShouldHaveSingleItem();
3737
}
3838
[Fact]
3939
public void Test2() {
@@ -57,7 +57,7 @@ public void Test2() {
5757

5858
// Find the first item in the table
5959
SweetWrapper? Sweet = Sweets.FindAll().FirstOrDefault();
60-
Assert.NotNull(Sweet);
60+
Sweet.ShouldNotBeNull();
6161
}
6262
}
6363

SQLiteSharp.Tests/SQLiteSharp.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<ItemGroup>
1111
<PackageReference Include="coverlet.collector" Version="6.0.4" />
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
13+
<PackageReference Include="Shouldly" Version="4.3.0" />
1314
<PackageReference Include="xunit" Version="2.9.3" />
1415
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2" />
1516
</ItemGroup>
@@ -20,5 +21,6 @@
2021

2122
<ItemGroup>
2223
<Using Include="Xunit" />
24+
<Using Include="Shouldly" />
2325
</ItemGroup>
2426
</Project>

0 commit comments

Comments
 (0)