Skip to content

Commit 54d1d5a

Browse files
committed
MSTest new APIs (stylecop, build fix)
1 parent 0b9cf65 commit 54d1d5a

File tree

10 files changed

+25
-18
lines changed

10 files changed

+25
-18
lines changed

Havit.Blazor.Components.Web.Bootstrap.Tests/Forms/HxInputDateRangeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public void HxInputDateRange_EnabledShouldOverrideFormStateForNestedControls_Iss
4343
{
4444
Assert.IsFalse(button.Find("button").HasAttribute("disabled"), $"Button {button.Instance.Text} should not be disabled.");
4545
}
46-
Assert.IsFalse(cut.Markup.Contains("disabled"), "There should be no disabled attribute in the rendered markup.");
46+
Assert.DoesNotContain("disabled", cut.Markup, "There should be no disabled attribute in the rendered markup.");
4747
}
4848
}

Havit.Blazor.Components.Web.Bootstrap.Tests/Forms/HxInputDateTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void HxInputDate_EnabledShouldOverrideFormStateForNestedControls_Issue877
4444
{
4545
Assert.IsFalse(button.Find("button").HasAttribute("disabled"), $"Button {button.Instance.Text} should not be disabled.");
4646
}
47-
Assert.IsFalse(cut.Markup.Contains("disabled"), "There should be no disabled attribute in the rendered markup.");
47+
Assert.DoesNotContain("disabled", cut.Markup, "There should be no disabled attribute in the rendered markup.");
4848
}
4949

5050
[TestMethod]

Havit.Blazor.Components.Web.Bootstrap.Tests/Forms/HxInputNumberTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Havit.Blazor.Components.Web.Bootstrap.Tests.Forms;
1111
[TestClass]
1212
public class HxInputNumberTests : BunitTestBase
1313
{
14-
[DataTestMethod]
14+
[TestMethod]
1515
[DataRow("en-US", "123", 123.0, "123.00")]
1616
[DataRow("en-US", "123,123", 123123.0, "123123.00")]
1717
[DataRow("cs-CZ", "123,123", 123.12, "123,12")] // Decimals = 2 (rounding)

Havit.Blazor.Components.Web.Bootstrap.Tests/Forms/HxInputTextTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void HxInputText_BindingToArrayOfString_Issue874()
2929
var cut = Render(componentRenderer);
3030

3131
// Assert
32-
Assert.IsFalse(cut.Markup.Contains("maxlength"));
32+
Assert.DoesNotContain("maxlength", cut.Markup);
3333
}
3434

3535
[TestMethod]
@@ -51,7 +51,7 @@ public void HxInputText_BindingToListOfString_Issue874()
5151
var cut = Render(componentRenderer);
5252

5353
// Assert
54-
Assert.IsFalse(cut.Markup.Contains("maxlength"));
54+
Assert.DoesNotContain("maxlength", cut.Markup);
5555
}
5656

5757
[TestMethod]
@@ -73,7 +73,7 @@ public void HxInputText_BindingToArrayOfModel_Issue874()
7373
var cut = Render(componentRenderer);
7474

7575
// Assert
76-
Assert.IsTrue(cut.Markup.Contains("maxlength=\"100\""));
76+
Assert.Contains("maxlength=\"100\"", cut.Markup);
7777
}
7878

7979
[TestMethod]
@@ -95,7 +95,7 @@ public void HxInputText_BindingToListOfModel_Issue874()
9595
var cut = Render(componentRenderer);
9696

9797
// Assert
98-
Assert.IsTrue(cut.Markup.Contains("maxlength=\"100\""));
98+
Assert.Contains("maxlength=\"100\"", cut.Markup);
9999
}
100100

101101
private record FormData

Havit.Blazor.Components.Web.Bootstrap.Tests/Grids/GridDataProviderRequestExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void GridDataProviderRequestExtensions_ApplyGridDataProviderRequest_InMem
3434
var result = source.ApplyGridDataProviderRequest(gridDataProviderRequest).ToList();
3535

3636
// Assert
37-
Assert.AreEqual(3, result.Count);
37+
Assert.HasCount(3, result);
3838
Assert.AreEqual(new Item { A = "1", B = 2 }, result[0]);
3939
Assert.AreEqual(new Item { A = "1", B = 1 }, result[1]);
4040
Assert.AreEqual(new Item { A = "2", B = 3 }, result[2]);

Havit.Blazor.Components.Web.Bootstrap.Tests/Grids/GridInternalStateSortingItemHelperTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void GridInternalStateSortingItemHelper_ApplyColumnToSorting_OnEmptySorti
2222
var newSorting = GridInternalStateSortingItemHelper.ApplyColumnToSorting(null, mockColumn.Object);
2323

2424
// Assert
25-
Assert.AreEqual(1, newSorting.Length);
25+
Assert.HasCount(1, newSorting);
2626
Assert.AreSame(mockColumn.Object, newSorting.Single().Column);
2727
Assert.IsFalse(newSorting.Single().ReverseDirection);
2828
}
@@ -47,7 +47,7 @@ public void GridInternalStateSortingItemHelper_ApplyColumnToSorting_TakesColumnT
4747
var newSorting = GridInternalStateSortingItemHelper.ApplyColumnToSorting(currentSorting, mockColumn2.Object);
4848

4949
// Assert
50-
Assert.AreEqual(2, newSorting.Length);
50+
Assert.HasCount(2, newSorting);
5151

5252
Assert.AreSame(mockColumn2.Object, newSorting[0].Column);
5353
Assert.IsFalse(newSorting[0].ReverseDirection);
@@ -73,7 +73,7 @@ public void GridInternalStateSortingItemHelper_ApplyColumnToSorting_TogglesRever
7373
var newSorting = GridInternalStateSortingItemHelper.ApplyColumnToSorting(currentSorting, mockColumn1.Object);
7474

7575
// Assert
76-
Assert.AreEqual(1, newSorting.Length);
76+
Assert.HasCount(1, newSorting);
7777

7878
Assert.AreSame(mockColumn1.Object, newSorting[0].Column);
7979
Assert.IsTrue(newSorting[0].ReverseDirection);
@@ -102,7 +102,7 @@ public void GridInternalStateSortingItemHelper_ToSortingItems_TwoSimpleColumns()
102102
var sortingItems = GridInternalStateSortingItemHelper.ToSortingItems(currentSorting);
103103

104104
// Assert
105-
Assert.AreEqual(2, sortingItems.Count);
105+
Assert.HasCount(2, sortingItems);
106106
Assert.AreEqual("A", sortingItems[0].SortString);
107107
Assert.AreEqual(SortDirection.Ascending, sortingItems[0].SortDirection);
108108
Assert.AreEqual("B", sortingItems[1].SortString);
@@ -135,7 +135,7 @@ public void GridInternalStateSortingItemHelper_ToSortingItems_TwoOverlappingColu
135135
var sortingItems = GridInternalStateSortingItemHelper.ToSortingItems(currentSorting);
136136

137137
// Assert
138-
Assert.AreEqual(2, sortingItems.Count);
138+
Assert.HasCount(2, sortingItems);
139139
Assert.AreEqual("A", sortingItems[0].SortString);
140140
Assert.AreEqual(SortDirection.Ascending, sortingItems[0].SortDirection);
141141
Assert.AreEqual("B", sortingItems[1].SortString);
@@ -165,7 +165,7 @@ public void GridInternalStateSortingItemHelper_ToSortingItems_TwoSameColumns()
165165
var sortingItems = GridInternalStateSortingItemHelper.ToSortingItems(currentSorting);
166166

167167
// Assert
168-
Assert.AreEqual(1, sortingItems.Count);
168+
Assert.HasCount(1, sortingItems);
169169
Assert.AreEqual("A", sortingItems[0].SortString);
170170
Assert.AreEqual(SortDirection.Ascending, sortingItems[0].SortDirection);
171171
}

Havit.Blazor.Components.Web.Tests/HxDynamicElementTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void HxDynamicElement_OnClickNotSet_ShouldNotSubscribeToClickEvent()
2626

2727
// Act + Assert
2828
var ex = Assert.ThrowsExactly<MissingEventHandlerException>(() => cut.Find("span").Click());
29-
Assert.IsTrue(ex.Message.Contains("The element does not have an event handler for the event 'onclick'"));
29+
Assert.Contains("The element does not have an event handler for the event 'onclick'", ex.Message);
3030
}
3131

3232
[TestMethod]

Havit.Blazor.Documentation.Tests/DemosSmokeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Havit.Blazor.Documentation.Tests;
1111
[TestClass]
1212
public class DemosSmokeTests
1313
{
14-
[DataTestMethod]
14+
[TestMethod]
1515
[DynamicData(nameof(GetDemos), DynamicDataSourceType.Method)]
1616
public void DocumentationDemo_SmokeTest(Type demoComponent)
1717
{

Havit.Blazor.Documentation.Tests/Services/ApiHelperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Havit.Blazor.Documentation.Tests.Services;
66
[TestClass]
77
public class ApiHelperTests
88
{
9-
[DataTestMethod]
9+
[TestMethod]
1010
[DataRow("AutosuggestDataProviderDelegate", true)]
1111
[DataRow("GridDataProviderDelegate", true)]
1212
[DataRow("InputTagsDataProviderDelegate", true)]

Havit.SourceGenerators.StrongApiStringLocalizers.Tests/StrongApiStringLocalizersGeneratorTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace Havit.SourceGenerators.StrongApiStringLocalizers.Tests;
88
[TestClass]
99
public class StrongApiStringLocalizersGeneratorTests
1010
{
11+
private readonly TestContext _testContext;
12+
1113
[TestMethod]
1214
public async Task StrongApiStringLocalizersGenerator_Test()
1315
{
@@ -119,6 +121,11 @@ public static IServiceCollection AddGeneratedResourceWrappers(this IServiceColle
119121
"));
120122

121123
// Act + Assert
122-
await test.RunAsync();
124+
await test.RunAsync(_testContext.CancellationTokenSource.Token);
125+
}
126+
127+
public StrongApiStringLocalizersGeneratorTests(TestContext testContext)
128+
{
129+
_testContext = testContext;
123130
}
124131
}

0 commit comments

Comments
 (0)