Skip to content

Commit 9172e2d

Browse files
authored
[FluentAssertions] Remove the FluentAssertions lib (microsoft#3701)
* Remove FluentAssertions * Fix unit test
1 parent 27496ab commit 9172e2d

15 files changed

+47
-68
lines changed

Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<PackageVersion Include="Microsoft.FluentUI.AspNetCore.Components.Emoji" Version="4.11.7" />
1919
<!-- Test dependencies -->
2020
<PackageVersion Include="bunit" Version="1.38.5" />
21-
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
2221
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
2322
<PackageVersion Include="xunit" Version="2.9.3" />
2423
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />

examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10128,7 +10128,7 @@
1012810128
</member>
1012910129
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentTooltip.Delay">
1013010130
<summary>
10131-
Gets or sets the delay (in milliseconds).
10131+
Gets or sets the delay (in milliseconds).
1013210132
Default is 300.
1013310133
</summary>
1013410134
</member>
@@ -10168,7 +10168,7 @@
1016810168
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentTooltip.OnDismissed">
1016910169
<summary>
1017010170
Callback for when the tooltip is dismissed.
10171-
</summary>
10171+
</summary>
1017210172
</member>
1017310173
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentTooltip.DrawTooltip">
1017410174
<summary />

tests/Core/Anchor/FluentAnchorTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Bunit;
2-
using FluentAssertions;
32
using Microsoft.Extensions.DependencyInjection;
43
using Xunit;
54

@@ -148,11 +147,10 @@ public void FluentAnchor_TargetAttribute(string target)
148147
// Assert
149148
if (target == "invalid")
150149
{
151-
action.Should().Throw<ArgumentException>();
150+
Assert.Throws< ArgumentException>(action);
152151
}
153152
else
154153
{
155-
action.Should().NotThrow();
156154
cut!.Verify(suffix: target);
157155
}
158156
}

tests/Core/Badge/FluentBadgeTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Bunit;
2-
using FluentAssertions;
2+
33
using Xunit;
44

55
namespace Microsoft.FluentUI.AspNetCore.Components.Tests.Badge;
@@ -42,11 +42,10 @@ public void FluentBadge_AppearanceAttribute(Appearance appearance)
4242
// Assert
4343
if (appearance == Appearance.Hypertext)
4444
{
45-
action.Should().Throw<ArgumentException>();
45+
Assert.Throws<ArgumentException>(action);
4646
}
4747
else
4848
{
49-
action.Should().NotThrow();
5049
cut!.Verify(suffix: appearance.ToString());
5150
}
5251
}
@@ -69,7 +68,7 @@ public void ThrowArgumentException_When_AppearanceAttributeValue_IsInvalid(Appea
6968
};
7069

7170
// Assert
72-
action.Should().ThrowExactly<ArgumentException>();
71+
Assert.Throws<ArgumentException>(action);
7372
}
7473

7574
[Fact]

tests/Core/Breadcrumb/FluentBreadcrumbItemTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Bunit;
2-
using FluentAssertions;
2+
33
using Xunit;
44

55
namespace Microsoft.FluentUI.AspNetCore.Components.Tests.Breadcrumb;
@@ -133,11 +133,10 @@ public void FluentBreadcrumbItem_TargetAttribute(string targetAttribute)
133133
// Assert
134134
if (targetAttribute == "invalid")
135135
{
136-
action.Should().Throw<ArgumentException>();
136+
Assert.Throws<ArgumentException>(action);
137137
}
138138
else
139139
{
140-
action.Should().NotThrow();
141140
cut!.Verify(suffix: targetAttribute);
142141
}
143142
}

tests/Core/Button/FluentButtonTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Bunit;
2-
using FluentAssertions;
2+
33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions;
55
using Xunit;
@@ -165,7 +165,7 @@ public void Throw_ArgumentException_When_FormTargetAttribute_IsInvalid(string? f
165165
};
166166

167167
// Assert
168-
action.Should().Throw<ArgumentException>();
168+
Assert.Throws<ArgumentException>(action);
169169
}
170170

171171
[Theory]

tests/Core/DataGrid/DataGridSortByTests.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@using Bunit
2-
@using FluentAssertions
32
@using Xunit
43

54
@inherits TestContext

tests/Core/DataGrid/FluentDataGridTests.razor

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using FluentAssertions
2-
@using Xunit
1+
@using Xunit
32
@inherits TestContext
43

54
@code {
@@ -43,14 +42,14 @@
4342
</FluentDataGrid>);
4443

4544
// Assert
46-
cut.Find("#loading-content").Should().NotBeNull();
45+
Assert.NotNull(cut.Find("#loading-content"));
4746
Assert.Throws<ElementNotFoundException>(() => cut.Find("#empty-content"));
4847

4948
cut.SetParametersAndRender(parameters => parameters
5049
.Add(p => p.Loading, false));
5150

5251
Assert.Throws<ElementNotFoundException>(() => cut.Find("#loading-content"));
53-
cut.Find("#empty-content").Should().NotBeNull();
52+
Assert.NotNull(cut.Find("#empty-content"));
5453
}
5554

5655
[Fact]
@@ -76,17 +75,17 @@
7675

7776
// Assert
7877
var dataGrid = cut.Instance;
79-
cut.Find("#loading-content").Should().NotBeNull();
78+
Assert.NotNull(cut.Find("#loading-content"));
8079

8180
// should stay loading even after data refresh
8281
await cut.InvokeAsync(() => dataGrid.RefreshDataAsync());
83-
cut.Find("#loading-content").Should().NotBeNull();
82+
Assert.NotNull(cut.Find("#loading-content"));
8483

8584
// now not loading but still with 0 items, should render empty content
8685
cut.SetParametersAndRender(parameters => parameters
8786
.Add(p => p.Loading, false));
8887

89-
cut.Find("#empty-content").Should().NotBeNull();
88+
Assert.NotNull(cut.Find("#empty-content"));
9089
}
9190

9291
[Fact]
@@ -117,7 +116,7 @@
117116
var dataGrid = cut.Instance;
118117

119118
// Data is still loading, so loading content should be displayed
120-
cut.Find("#loading-content").Should().NotBeNull();
119+
Assert.NotNull(cut.Find("#loading-content"));
121120

122121
tcs.SetResult();
123122

@@ -136,7 +135,7 @@
136135
tcs = new TaskCompletionSource();
137136
cut.SetParametersAndRender(parameters => parameters
138137
.Add(p => p.Loading, null));
139-
cut.Find("#loading-content").Should().NotBeNull();
138+
Assert.NotNull(cut.Find("#loading-content"));
140139

141140
tcs.SetResult();
142141

tests/Core/DataGrid/GridSortTests.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using FluentAssertions;
1+
22
using Xunit;
33

44
namespace Microsoft.FluentUI.AspNetCore.Components.Tests.DataGrid;
@@ -22,9 +22,7 @@ public void GridSortTests_SortBy_Number(bool ascending, IList<int> expected)
2222
var sort = GridSort<GridRow>.ByAscending(x => x.Number);
2323
var ordered = sort.Apply(_gridData.AsQueryable(), ascending);
2424

25-
ordered.Select(x => x.Number)
26-
.SequenceEqual(expected)
27-
.Should().BeTrue();
25+
Assert.True(ordered.Select(x => x.Number).SequenceEqual(expected));
2826
}
2927

3028
[Theory]
@@ -38,9 +36,7 @@ public void GridSortTests_SortBy_GroupThenNumberAscending(bool ascending, IList<
3836

3937
var ordered = sort.Apply(_gridData.AsQueryable(), ascending);
4038

41-
ordered.Select(x => x.Number)
42-
.SequenceEqual(expected)
43-
.Should().BeTrue();
39+
Assert.True(ordered.Select(x => x.Number).SequenceEqual(expected));
4440
}
4541

4642
[Theory]
@@ -54,9 +50,7 @@ public void GridSortTests_SortBy_GroupThenNumberDescending(bool ascending, IList
5450

5551
var ordered = sort.Apply(_gridData.AsQueryable(), ascending);
5652

57-
ordered.Select(x => x.Number)
58-
.SequenceEqual(expected)
59-
.Should().BeTrue();
53+
Assert.True(ordered.Select(x => x.Number).SequenceEqual(expected));
6054
}
6155

6256
[Theory]
@@ -70,9 +64,7 @@ public void GridSortTests_SortBy_GroupThenNumberAlwaysAscending(bool ascending,
7064

7165
var ordered = sort.Apply(_gridData.AsQueryable(), ascending);
7266

73-
ordered.Select(x => x.Number)
74-
.SequenceEqual(expected)
75-
.Should().BeTrue();
67+
Assert.True(ordered.Select(x => x.Number).SequenceEqual(expected));
7668
}
7769

7870
[Theory]
@@ -86,9 +78,7 @@ public void GridSortTests_SortBy_GroupThenNumberAlwaysDescending(bool ascending,
8678

8779
var ordered = sort.Apply(_gridData.AsQueryable(), ascending);
8880

89-
ordered.Select(x => x.Number)
90-
.SequenceEqual(expected)
91-
.Should().BeTrue();
81+
Assert.True(ordered.Select(x => x.Number).SequenceEqual(expected));
9282
}
9383

9484
#pragma warning restore CA1861 // Avoid constant arrays as arguments

tests/Core/FluentAssert.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using AngleSharp.Dom;
44
using Bunit;
55
using Bunit.Rendering;
6-
using FluentAssertions;
6+
77
using Microsoft.Extensions.DependencyInjection;
88

99
namespace Microsoft.FluentUI.AspNetCore.Components.Tests;

tests/Core/List/FluentAutocompleteTests.razor

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using FluentAssertions
2-
@using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions
1+
@using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions
32
@using Xunit;
43
@inherits TestContext
54
@code
@@ -260,11 +259,11 @@
260259
var valueAttribute = textField.Attributes["value"];
261260
var currentValueAttribute = textField.Attributes["current-value"];
262261

263-
valueAttribute.Should().NotBeNull();
264-
valueAttribute!.Value.Should().Be("Preselected value");
262+
Assert.NotNull(valueAttribute);
263+
Assert.Equal("Preselected value", valueAttribute!.Value);
265264

266-
currentValueAttribute.Should().NotBeNull();
267-
currentValueAttribute!.Value.Should().Be("Preselected value");
265+
Assert.NotNull(currentValueAttribute);
266+
Assert.Equal("Preselected value", currentValueAttribute!.Value);
268267

269268
cut.Verify();
270269
}
@@ -280,13 +279,13 @@
280279
parameters.Bind(p => p.ValueText, valueText, x => valueText = x);
281280
});
282281

283-
valueText.Should().NotBeNullOrEmpty();
282+
Assert.False(string.IsNullOrEmpty(valueText));
284283

285284
// Act
286285
cut.Find("svg").Click(); // Clear button
287286
288287
// Assert
289-
valueText.Should().BeNullOrEmpty();
288+
Assert.True(string.IsNullOrEmpty(valueText));
290289

291290
cut.Verify();
292291
}
@@ -305,7 +304,7 @@
305304
cut.Find("svg").Click(); // Clear button
306305
307306
// Assert
308-
cut.Find("fluent-anchored-region").Should().NotBeNull();
307+
Assert.NotNull(cut.Find("fluent-anchored-region"));
309308
cut.Verify();
310309
}
311310

@@ -324,7 +323,7 @@
324323
cut.Find("svg").Click(); // Clear button
325324
326325
// Assert
327-
cut.FindAll("fluent-anchored-region").Should().BeNullOrEmpty();
326+
Assert.Empty(cut.FindAll("fluent-anchored-region"));
328327
cut.Verify();
329328
}
330329

tests/Core/List/FluentListboxTests.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using FluentAssertions
2-
@using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions
1+
@using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions
32
@using Xunit;
43
@inherits TestContext
54
@code

tests/Core/List/FluentSelectTests.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using FluentAssertions
2-
@using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions
1+
@using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions
32
@using Xunit;
43
@inherits TestContext
54
@code

tests/Core/Microsoft.FluentUI.AspNetCore.Components.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="bunit" />
14-
<PackageReference Include="FluentAssertions" />
1514
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1615
<PackageReference Include="xunit" />
1716
<PackageReference Include="xunit.runner.visualstudio">

0 commit comments

Comments
 (0)