diff --git a/src/ConfigWay.PostgreSQL.Tests/ConfigWay.PostgreSQL.Tests.csproj b/src/ConfigWay.PostgreSQL.Tests/ConfigWay.PostgreSQL.Tests.csproj
index 9b6d9d4..ca595c4 100644
--- a/src/ConfigWay.PostgreSQL.Tests/ConfigWay.PostgreSQL.Tests.csproj
+++ b/src/ConfigWay.PostgreSQL.Tests/ConfigWay.PostgreSQL.Tests.csproj
@@ -18,7 +18,6 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
diff --git a/src/ConfigWay.PostgreSQL.Tests/Integration/PostgresApiTests.cs b/src/ConfigWay.PostgreSQL.Tests/Integration/PostgresApiTests.cs
index 8c92f74..359d69f 100644
--- a/src/ConfigWay.PostgreSQL.Tests/Integration/PostgresApiTests.cs
+++ b/src/ConfigWay.PostgreSQL.Tests/Integration/PostgresApiTests.cs
@@ -1,7 +1,6 @@
using System.Net;
using System.Net.Http.Json;
using System.Text.Json;
-using FluentAssertions;
using Kododo.ConfigWay.PostgreSQL.Tests.Fixtures;
using Kododo.ConfigWay.UI;
using Microsoft.AspNetCore.Builder;
@@ -52,7 +51,7 @@ public async Task DisposeAsync()
public async Task GetConfiguration_Returns200()
{
var response = await PostGetConfiguration();
- response.StatusCode.Should().Be(HttpStatusCode.OK);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
[Fact]
@@ -60,15 +59,15 @@ public async Task GetConfiguration_ReturnsRegisteredOptions()
{
var sections = await FetchSections();
- sections.Should().HaveCount(2);
- sections.Select(s => s.Key).Should().BeEquivalentTo("Simple", "Nested");
+ Assert.Equal(2, sections.Length);
+ Assert.Equivalent(new[] { "Simple", "Nested" }, sections.Select(s => s.Key), strict: true);
}
[Fact]
public async Task GetConfiguration_InitialValues_AreNull()
{
var sections = await FetchSections();
- sections.SelectMany(s => s.Fields).Should().AllSatisfy(f => f.Value.Should().BeNull());
+ Assert.All(sections.SelectMany(s => s.Fields), f => Assert.Null(f.Value));
}
[Fact]
@@ -76,9 +75,10 @@ public async Task UpdateConfiguration_ValidSettings_Returns200WithEmptyErrors()
{
var response = await PostUpdate(new[] { new { key = "Simple:Name", value = "Alice" } });
- response.StatusCode.Should().Be(HttpStatusCode.OK);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var errors = await response.Content.ReadFromJsonAsync();
- errors.Should().BeEmpty();
+ Assert.NotNull(errors);
+ Assert.Empty(errors);
}
[Fact]
@@ -89,7 +89,7 @@ public async Task UpdateConfiguration_AfterSave_GetReturnsUpdatedValue()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Alice");
+ Assert.Equal("Alice", field.Value);
}
[Fact]
@@ -104,7 +104,7 @@ public async Task UpdateConfiguration_PersistedToPostgres_SurvivesAppRestart()
var sections = (await response.Content.ReadFromJsonAsync())!;
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Persistent");
+ Assert.Equal("Persistent", field.Value);
}
[Fact]
@@ -116,7 +116,7 @@ public async Task UpdateConfiguration_MultipleUpdates_LastValueWins()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Second");
+ Assert.Equal("Second", field.Value);
}
[Fact]
@@ -133,8 +133,8 @@ await PostUpdate(new[]
var sections = await FetchSections();
var fields = sections.Single(s => s.Key == "Simple").Fields;
- fields.Single(f => f.Key == "Name").Value.Should().Be("Bob");
- fields.Single(f => f.Key == "Value").Value.Should().Be("42");
+ Assert.Equal("Bob", fields.Single(f => f.Key == "Name").Value);
+ Assert.Equal("42", fields.Single(f => f.Key == "Value").Value);
}
[Fact]
@@ -146,7 +146,7 @@ public async Task UpdateConfiguration_NestedField_PersistedAndRetrieved()
var subSection = sections.Single(s => s.Key == "Nested").Sections.Single(s => s.Key == "Child");
var field = subSection.Fields.Single(f => f.Key == "ChildProp");
- field.Value.Should().Be("deep");
+ Assert.Equal("deep", field.Value);
}
[Fact]
@@ -158,7 +158,7 @@ public async Task UpdateConfiguration_NullValue_ClearsField()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().BeNull();
+ Assert.Null(field.Value);
}
private Task PostGetConfiguration() =>
diff --git a/src/ConfigWay.PostgreSQL.Tests/StoreTests.cs b/src/ConfigWay.PostgreSQL.Tests/StoreTests.cs
index 555ff45..8453878 100644
--- a/src/ConfigWay.PostgreSQL.Tests/StoreTests.cs
+++ b/src/ConfigWay.PostgreSQL.Tests/StoreTests.cs
@@ -1,4 +1,3 @@
-using FluentAssertions;
using Kododo.ConfigWay.Core.Model;
using Kododo.ConfigWay.PostgreSQL.Tests.Fixtures;
using Xunit;
@@ -27,21 +26,20 @@ public async Task InitializeAsync_CreatesSchemaAndTable()
{
await _store.SetAsync([new Setting("probe", "ok")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "probe");
+ Assert.Single(result, s => s.Key == "probe");
}
[Fact]
public async Task InitializeAsync_WhenCalledTwice_IsIdempotent()
{
- var act = async () => await _store.InitializeAsync();
- await act.Should().NotThrowAsync();
+ await _store.InitializeAsync();
}
[Fact]
public async Task GetAll_WhenTableIsEmpty_ReturnsEmptyList()
{
var result = await _store.GetAllAsync();
- result.Should().BeEmpty();
+ Assert.Empty(result);
}
[Fact]
@@ -55,8 +53,8 @@ await _store.SetAsync([
var result = await _store.GetAllAsync();
- result.Should().HaveCount(3);
- result.Select(s => s.Key).Should().BeEquivalentTo("Key1", "Key2", "Key3");
+ Assert.Equal(3, result.Count);
+ Assert.Equivalent(new[] { "Key1", "Key2", "Key3" }, result.Select(s => s.Key), strict: true);
}
[Fact]
@@ -66,7 +64,7 @@ public async Task GetAll_WhenValueIsNull_ReturnsSettingWithNullValue()
var result = await _store.GetAllAsync();
- result.Single(s => s.Key == "NullKey").Value.Should().BeNull();
+ Assert.Null(result.Single(s => s.Key == "NullKey").Value);
}
[Fact]
@@ -75,7 +73,7 @@ public async Task Set_NewKey_InsertsRow()
await _store.SetAsync([new Setting("New", "value")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "New" && s.Value == "value");
+ Assert.Single(result, s => s.Key == "New" && s.Value == "value");
}
[Fact]
@@ -85,8 +83,8 @@ public async Task Set_ExistingKey_UpdatesValueInPlace()
await _store.SetAsync([new Setting("Key", "NewValue")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle();
- result.Single().Value.Should().Be("NewValue");
+ Assert.Single(result);
+ Assert.Equal("NewValue", result.Single().Value);
}
[Fact]
@@ -97,7 +95,7 @@ public async Task Set_ExistingKey_DoesNotDuplicateRow()
await _store.SetAsync([new Setting("Key", "C")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "Key");
+ Assert.Single(result, s => s.Key == "Key");
}
[Fact]
@@ -106,7 +104,7 @@ public async Task Set_NullValue_StoredAndRetrievedAsNull()
await _store.SetAsync([new Setting("Key", null)]);
var result = await _store.GetAllAsync();
- result.Single().Value.Should().BeNull();
+ Assert.Null(result.Single().Value);
}
[Fact]
@@ -116,7 +114,7 @@ public async Task Set_NullThenNonNull_Overwrites()
await _store.SetAsync([new Setting("Key", "value")]);
var result = await _store.GetAllAsync();
- result.Single().Value.Should().Be("value");
+ Assert.Equal("value", result.Single().Value);
}
[Fact]
@@ -129,7 +127,7 @@ public async Task Set_MultipleSettings_AllInsertedInSingleCall()
await _store.SetAsync(settings);
var result = await _store.GetAllAsync();
- result.Should().HaveCount(10);
+ Assert.Equal(10, result.Count);
}
[Fact]
@@ -140,10 +138,10 @@ public async Task Set_AfterPartialInsert_RollsBackAllChanges()
var brokenStore = new Store("Host=127.0.0.1;Port=9;Database=x;Username=x;Password=x");
var act = async () => await brokenStore.SetAsync([new Setting("K", "V")]);
- await act.Should().ThrowAsync();
+ await Assert.ThrowsAnyAsync(act);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "Existing" && s.Value == "before");
+ Assert.Single(result, s => s.Key == "Existing" && s.Value == "before");
}
[Fact]
@@ -155,7 +153,7 @@ public async Task Set_DataPersistedAcrossStoreInstances()
await freshStore.InitializeAsync();
var result = await freshStore.GetAllAsync();
- result.Should().Contain(s => s.Key == "Persistent" && s.Value == "data");
+ Assert.Contains(result, s => s.Key == "Persistent" && s.Value == "data");
}
}
diff --git a/src/ConfigWay.SqlServer.Tests/ConfigWay.SqlServer.Tests.csproj b/src/ConfigWay.SqlServer.Tests/ConfigWay.SqlServer.Tests.csproj
index 1f4bb31..b742927 100644
--- a/src/ConfigWay.SqlServer.Tests/ConfigWay.SqlServer.Tests.csproj
+++ b/src/ConfigWay.SqlServer.Tests/ConfigWay.SqlServer.Tests.csproj
@@ -18,7 +18,6 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
diff --git a/src/ConfigWay.SqlServer.Tests/Integration/SqlServerApiTests.cs b/src/ConfigWay.SqlServer.Tests/Integration/SqlServerApiTests.cs
index c8c00c0..5f46efb 100644
--- a/src/ConfigWay.SqlServer.Tests/Integration/SqlServerApiTests.cs
+++ b/src/ConfigWay.SqlServer.Tests/Integration/SqlServerApiTests.cs
@@ -1,7 +1,6 @@
using System.Net;
using System.Net.Http.Json;
using System.Text.Json;
-using FluentAssertions;
using Kododo.ConfigWay.SqlServer.Tests.Fixtures;
using Kododo.ConfigWay.UI;
using Microsoft.AspNetCore.Builder;
@@ -52,7 +51,7 @@ public async Task DisposeAsync()
public async Task GetConfiguration_Returns200()
{
var response = await PostGetConfiguration();
- response.StatusCode.Should().Be(HttpStatusCode.OK);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
[Fact]
@@ -60,15 +59,15 @@ public async Task GetConfiguration_ReturnsRegisteredOptions()
{
var sections = await FetchSections();
- sections.Should().HaveCount(2);
- sections.Select(s => s.Key).Should().BeEquivalentTo("Simple", "Nested");
+ Assert.Equal(2, sections.Length);
+ Assert.Equivalent(new[] { "Simple", "Nested" }, sections.Select(s => s.Key), strict: true);
}
[Fact]
public async Task GetConfiguration_InitialValues_AreNull()
{
var sections = await FetchSections();
- sections.SelectMany(s => s.Fields).Should().AllSatisfy(f => f.Value.Should().BeNull());
+ Assert.All(sections.SelectMany(s => s.Fields), f => Assert.Null(f.Value));
}
[Fact]
@@ -76,9 +75,10 @@ public async Task UpdateConfiguration_ValidSettings_Returns200WithEmptyErrors()
{
var response = await PostUpdate(new[] { new { key = "Simple:Name", value = "Alice" } });
- response.StatusCode.Should().Be(HttpStatusCode.OK);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var errors = await response.Content.ReadFromJsonAsync();
- errors.Should().BeEmpty();
+ Assert.NotNull(errors);
+ Assert.Empty(errors);
}
[Fact]
@@ -89,7 +89,7 @@ public async Task UpdateConfiguration_AfterSave_GetReturnsUpdatedValue()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Alice");
+ Assert.Equal("Alice", field.Value);
}
[Fact]
@@ -104,7 +104,7 @@ public async Task UpdateConfiguration_PersistedToSqlServer_SurvivesAppRestart()
var sections = (await response.Content.ReadFromJsonAsync())!;
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Persistent");
+ Assert.Equal("Persistent", field.Value);
}
[Fact]
@@ -116,7 +116,7 @@ public async Task UpdateConfiguration_MultipleUpdates_LastValueWins()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Second");
+ Assert.Equal("Second", field.Value);
}
[Fact]
@@ -133,8 +133,8 @@ await PostUpdate(new[]
var sections = await FetchSections();
var fields = sections.Single(s => s.Key == "Simple").Fields;
- fields.Single(f => f.Key == "Name").Value.Should().Be("Bob");
- fields.Single(f => f.Key == "Value").Value.Should().Be("42");
+ Assert.Equal("Bob", fields.Single(f => f.Key == "Name").Value);
+ Assert.Equal("42", fields.Single(f => f.Key == "Value").Value);
}
[Fact]
@@ -146,7 +146,7 @@ public async Task UpdateConfiguration_NestedField_PersistedAndRetrieved()
var subSection = sections.Single(s => s.Key == "Nested").Sections.Single(s => s.Key == "Child");
var field = subSection.Fields.Single(f => f.Key == "ChildProp");
- field.Value.Should().Be("deep");
+ Assert.Equal("deep", field.Value);
}
[Fact]
@@ -158,7 +158,7 @@ public async Task UpdateConfiguration_NullValue_ClearsField()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().BeNull();
+ Assert.Null(field.Value);
}
private Task PostGetConfiguration() =>
diff --git a/src/ConfigWay.SqlServer.Tests/StoreTests.cs b/src/ConfigWay.SqlServer.Tests/StoreTests.cs
index a988ef8..e7ed1ff 100644
--- a/src/ConfigWay.SqlServer.Tests/StoreTests.cs
+++ b/src/ConfigWay.SqlServer.Tests/StoreTests.cs
@@ -1,4 +1,3 @@
-using FluentAssertions;
using Kododo.ConfigWay.Core.Model;
using Kododo.ConfigWay.SqlServer.Tests.Fixtures;
using Xunit;
@@ -27,21 +26,20 @@ public async Task InitializeAsync_CreatesSchemaAndTable()
{
await _store.SetAsync([new Setting("probe", "ok")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "probe");
+ Assert.Single(result, s => s.Key == "probe");
}
[Fact]
public async Task InitializeAsync_WhenCalledTwice_IsIdempotent()
{
- var act = async () => await _store.InitializeAsync();
- await act.Should().NotThrowAsync();
+ await _store.InitializeAsync();
}
[Fact]
public async Task GetAll_WhenTableIsEmpty_ReturnsEmptyList()
{
var result = await _store.GetAllAsync();
- result.Should().BeEmpty();
+ Assert.Empty(result);
}
[Fact]
@@ -55,8 +53,8 @@ await _store.SetAsync([
var result = await _store.GetAllAsync();
- result.Should().HaveCount(3);
- result.Select(s => s.Key).Should().BeEquivalentTo("Key1", "Key2", "Key3");
+ Assert.Equal(3, result.Count);
+ Assert.Equivalent(new[] { "Key1", "Key2", "Key3" }, result.Select(s => s.Key), strict: true);
}
[Fact]
@@ -66,7 +64,7 @@ public async Task GetAll_WhenValueIsNull_ReturnsSettingWithNullValue()
var result = await _store.GetAllAsync();
- result.Single(s => s.Key == "NullKey").Value.Should().BeNull();
+ Assert.Null(result.Single(s => s.Key == "NullKey").Value);
}
[Fact]
@@ -75,7 +73,7 @@ public async Task Set_NewKey_InsertsRow()
await _store.SetAsync([new Setting("New", "value")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "New" && s.Value == "value");
+ Assert.Single(result, s => s.Key == "New" && s.Value == "value");
}
[Fact]
@@ -85,8 +83,8 @@ public async Task Set_ExistingKey_UpdatesValueInPlace()
await _store.SetAsync([new Setting("Key", "NewValue")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle();
- result.Single().Value.Should().Be("NewValue");
+ Assert.Single(result);
+ Assert.Equal("NewValue", result.Single().Value);
}
[Fact]
@@ -97,7 +95,7 @@ public async Task Set_ExistingKey_DoesNotDuplicateRow()
await _store.SetAsync([new Setting("Key", "C")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "Key");
+ Assert.Single(result, s => s.Key == "Key");
}
[Fact]
@@ -106,7 +104,7 @@ public async Task Set_NullValue_StoredAndRetrievedAsNull()
await _store.SetAsync([new Setting("Key", null)]);
var result = await _store.GetAllAsync();
- result.Single().Value.Should().BeNull();
+ Assert.Null(result.Single().Value);
}
[Fact]
@@ -116,7 +114,7 @@ public async Task Set_NullThenNonNull_Overwrites()
await _store.SetAsync([new Setting("Key", "value")]);
var result = await _store.GetAllAsync();
- result.Single().Value.Should().Be("value");
+ Assert.Equal("value", result.Single().Value);
}
[Fact]
@@ -129,7 +127,7 @@ public async Task Set_MultipleSettings_AllInsertedInSingleCall()
await _store.SetAsync(settings);
var result = await _store.GetAllAsync();
- result.Should().HaveCount(10);
+ Assert.Equal(10, result.Count);
}
[Fact]
@@ -140,10 +138,10 @@ public async Task Set_AfterPartialInsert_RollsBackAllChanges()
var brokenStore = new Store("Server=127.0.0.1,1;Database=x;User Id=x;Password=x;TrustServerCertificate=True;Connect Timeout=1");
var act = async () => await brokenStore.SetAsync([new Setting("K", "V")]);
- await act.Should().ThrowAsync();
+ await Assert.ThrowsAnyAsync(act);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "Existing" && s.Value == "before");
+ Assert.Single(result, s => s.Key == "Existing" && s.Value == "before");
}
[Fact]
@@ -155,7 +153,7 @@ public async Task Set_DataPersistedAcrossStoreInstances()
await freshStore.InitializeAsync();
var result = await freshStore.GetAllAsync();
- result.Should().Contain(s => s.Key == "Persistent" && s.Value == "data");
+ Assert.Contains(result, s => s.Key == "Persistent" && s.Value == "data");
}
}
diff --git a/src/ConfigWay.Tests/ConfigWay.Tests.csproj b/src/ConfigWay.Tests/ConfigWay.Tests.csproj
index b1a065d..2877e0f 100644
--- a/src/ConfigWay.Tests/ConfigWay.Tests.csproj
+++ b/src/ConfigWay.Tests/ConfigWay.Tests.csproj
@@ -18,7 +18,6 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
diff --git a/src/ConfigWay.Tests/Integration/ConfigurationApiTests.cs b/src/ConfigWay.Tests/Integration/ConfigurationApiTests.cs
index 443909b..d96edfb 100644
--- a/src/ConfigWay.Tests/Integration/ConfigurationApiTests.cs
+++ b/src/ConfigWay.Tests/Integration/ConfigurationApiTests.cs
@@ -2,7 +2,6 @@
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
-using FluentAssertions;
using Kododo.ConfigWay.Core.Model;
using Kododo.ConfigWay.UI;
using Microsoft.AspNetCore.Builder;
@@ -53,7 +52,7 @@ public async Task DisposeAsync()
public async Task GetConfiguration_Returns200()
{
var response = await PostGetConfiguration();
- response.StatusCode.Should().Be(HttpStatusCode.OK);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
[Fact]
@@ -61,9 +60,11 @@ public async Task GetConfiguration_ReturnsRegisteredSections()
{
var sections = await FetchSections();
- sections.Should().HaveCount(5);
- sections.Select(s => s.Key)
- .Should().BeEquivalentTo("Simple", "Nested", "Typed", "Arrays", "Complex");
+ Assert.Equal(5, sections.Length);
+ Assert.Equivalent(
+ new[] { "Simple", "Nested", "Typed", "Arrays", "Complex" },
+ sections.Select(s => s.Key),
+ strict: true);
}
[Fact]
@@ -72,9 +73,9 @@ public async Task GetConfiguration_FlatSection_ContainsExpectedFields()
var sections = await FetchSections();
var simple = sections.Single(s => s.Key == "Simple");
- simple.Fields.Select(f => f.Key).Should().BeEquivalentTo("Name", "Value");
- simple.Sections.Should().BeEmpty();
- simple.Arrays.Should().BeEmpty();
+ Assert.Equivalent(new[] { "Name", "Value" }, simple.Fields.Select(f => f.Key), strict: true);
+ Assert.Empty(simple.Sections);
+ Assert.Empty(simple.Arrays);
}
[Fact]
@@ -83,8 +84,8 @@ public async Task GetConfiguration_NestedSection_ContainsSubSection()
var sections = await FetchSections();
var nested = sections.Single(s => s.Key == "Nested");
- nested.Fields.Should().ContainSingle(f => f.Key == "TopLevel");
- nested.Sections.Should().ContainSingle(s => s.Key == "Child");
+ Assert.Single(nested.Fields, f => f.Key == "TopLevel");
+ Assert.Single(nested.Sections, s => s.Key == "Child");
}
[Fact]
@@ -92,8 +93,7 @@ public async Task GetConfiguration_InitialValues_AreNull()
{
var sections = await FetchSections();
- sections.SelectMany(s => s.Fields)
- .Should().AllSatisfy(f => f.Value.Should().BeNull());
+ Assert.All(sections.SelectMany(s => s.Fields), f => Assert.Null(f.Value));
}
[Fact]
@@ -102,9 +102,10 @@ public async Task UpdateConfiguration_ValidSettings_Returns200WithEmptyErrors()
var settings = new[] { new Setting("Simple:Name", "Alice") };
var response = await PostUpdateConfiguration(settings);
- response.StatusCode.Should().Be(HttpStatusCode.OK);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var errors = await response.Content.ReadFromJsonAsync();
- errors.Should().BeEmpty();
+ Assert.NotNull(errors);
+ Assert.Empty(errors);
}
[Fact]
@@ -117,7 +118,7 @@ public async Task UpdateConfiguration_AfterSave_GetReturnsUpdatedValue()
.Single(s => s.Key == "Simple")
.Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Alice");
+ Assert.Equal("Alice", field.Value);
}
[Fact]
@@ -129,7 +130,7 @@ public async Task UpdateConfiguration_MultipleUpdates_LastValueWins()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Second");
+ Assert.Equal("Second", field.Value);
}
[Fact]
@@ -145,8 +146,8 @@ await PostUpdateConfiguration([
var sections = await FetchSections();
var fields = sections.Single(s => s.Key == "Simple").Fields;
- fields.Single(f => f.Key == "Name").Value.Should().Be("Bob");
- fields.Single(f => f.Key == "Value").Value.Should().Be("42");
+ Assert.Equal("Bob", fields.Single(f => f.Key == "Name").Value);
+ Assert.Equal("42", fields.Single(f => f.Key == "Value").Value);
}
[Fact]
@@ -158,7 +159,7 @@ public async Task UpdateConfiguration_NestedField_SavedAndRetrieved()
var subSection = sections.Single(s => s.Key == "Nested").Sections.Single();
var field = subSection.Fields.Single(f => f.Key == "ChildProp");
- field.Value.Should().Be("deep");
+ Assert.Equal("deep", field.Value);
}
[Fact]
@@ -170,7 +171,7 @@ public async Task UpdateConfiguration_NullValue_StoredAndReturned()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().BeNull();
+ Assert.Null(field.Value);
}
[Fact]
@@ -178,7 +179,7 @@ public async Task GetConfiguration_StringField_HasStringType()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Label");
- field.Type.Should().Be("String");
+ Assert.Equal("String", field.Type);
}
[Fact]
@@ -186,7 +187,7 @@ public async Task GetConfiguration_BoolField_HasBoolType()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Enabled");
- field.Type.Should().Be("Bool");
+ Assert.Equal("Bool", field.Type);
}
[Fact]
@@ -194,7 +195,7 @@ public async Task GetConfiguration_NumberField_HasNumberType()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Count");
- field.Type.Should().Be("Number");
+ Assert.Equal("Number", field.Type);
}
[Fact]
@@ -202,7 +203,7 @@ public async Task GetConfiguration_EnumField_HasEnumType()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Level");
- field.Type.Should().Be("Enum");
+ Assert.Equal("Enum", field.Type);
}
[Fact]
@@ -210,8 +211,8 @@ public async Task GetConfiguration_EnumField_ReturnsOptions()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Level");
- field.Options.Should().NotBeNull();
- field.Options!.Select(o => o.Value).Should().BeEquivalentTo("Low", "Medium", "High");
+ Assert.NotNull(field.Options);
+ Assert.Equivalent(new[] { "Low", "Medium", "High" }, field.Options!.Select(o => o.Value), strict: true);
}
[Fact]
@@ -219,9 +220,9 @@ public async Task GetConfiguration_EnumField_DisplayAttributeAppliedToLabels()
{
var sections = await FetchSections();
var options = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Level").Options!;
- options.Single(o => o.Value == "Low").Label.Should().Be("Low priority");
- options.Single(o => o.Value == "High").Label.Should().Be("High priority");
- options.Single(o => o.Value == "Medium").Label.Should().Be("Medium");
+ Assert.Equal("Low priority", options.Single(o => o.Value == "Low").Label);
+ Assert.Equal("High priority", options.Single(o => o.Value == "High").Label);
+ Assert.Equal("Medium", options.Single(o => o.Value == "Medium").Label);
}
[Fact]
@@ -231,7 +232,7 @@ public async Task UpdateConfiguration_BoolValue_SavedAndRetrieved()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Enabled");
- field.Value.Should().Be("True");
+ Assert.Equal("True", field.Value);
}
[Fact]
@@ -241,7 +242,7 @@ public async Task UpdateConfiguration_IntValue_SavedAndRetrieved()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Count");
- field.Value.Should().Be("99");
+ Assert.Equal("99", field.Value);
}
[Fact]
@@ -251,7 +252,7 @@ public async Task UpdateConfiguration_EnumValue_SavedAndRetrieved()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Typed").Fields.Single(f => f.Key == "Level");
- field.Value.Should().Be("High");
+ Assert.Equal("High", field.Value);
}
[Fact]
@@ -260,8 +261,8 @@ public async Task GetConfiguration_SimpleArraySection_HasArrayEntry()
var sections = await FetchSections();
var section = sections.Single(s => s.Key == "Arrays");
- section.Arrays.Should().Contain(a => a.Key == "Tags");
- section.Arrays.Should().Contain(a => a.Key == "Ports");
+ Assert.Contains(section.Arrays, a => a.Key == "Tags");
+ Assert.Contains(section.Arrays, a => a.Key == "Ports");
}
[Fact]
@@ -270,7 +271,7 @@ public async Task GetConfiguration_SimpleStringArray_IsSimpleTrue()
var sections = await FetchSections();
var arr = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags");
- arr.IsSimple.Should().BeTrue();
+ Assert.True(arr.IsSimple);
}
[Fact]
@@ -279,7 +280,7 @@ public async Task GetConfiguration_SimpleStringArray_TemplateTypeIsString()
var sections = await FetchSections();
var arr = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags");
- arr.Template.Type.Should().Be("String");
+ Assert.Equal("String", arr.Template.Type);
}
[Fact]
@@ -288,7 +289,7 @@ public async Task GetConfiguration_SimpleIntArray_TemplateTypeIsNumber()
var sections = await FetchSections();
var arr = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Ports");
- arr.Template.Type.Should().Be("Number");
+ Assert.Equal("Number", arr.Template.Type);
}
[Fact]
@@ -297,7 +298,7 @@ public async Task GetConfiguration_SimpleArray_InitiallyHasNoItems()
var sections = await FetchSections();
var arr = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags");
- arr.Items.Should().BeEmpty();
+ Assert.Empty(arr.Items);
}
[Fact]
@@ -306,7 +307,7 @@ public async Task GetConfiguration_ComplexArray_IsSimpleFalse()
var sections = await FetchSections();
var arr = sections.Single(s => s.Key == "Complex").Arrays.Single(a => a.Key == "Items");
- arr.IsSimple.Should().BeFalse();
+ Assert.False(arr.IsSimple);
}
[Fact]
@@ -315,9 +316,11 @@ public async Task GetConfiguration_ComplexArray_TemplateHasFields()
var sections = await FetchSections();
var arr = sections.Single(s => s.Key == "Complex").Arrays.Single(a => a.Key == "Items");
- arr.Template.Fields.Should().NotBeEmpty();
- arr.Template.Fields.Select(f => f.Key)
- .Should().BeEquivalentTo("Name", "Priority", "Category");
+ Assert.NotEmpty(arr.Template.Fields);
+ Assert.Equivalent(
+ new[] { "Name", "Priority", "Category" },
+ arr.Template.Fields.Select(f => f.Key),
+ strict: true);
}
[Fact]
@@ -328,7 +331,7 @@ public async Task UpdateConfiguration_AddSimpleArrayItem_CanBeRetrieved()
var sections = await FetchSections();
var arr = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags");
- arr.Items.Should().ContainSingle(i => i.Index == 0 && i.Value == "production");
+ Assert.Single(arr.Items, i => i.Index == 0 && i.Value == "production");
}
[Fact]
@@ -343,8 +346,8 @@ await PostUpdateConfiguration([
var sections = await FetchSections();
var items = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags").Items;
- items.Should().HaveCount(3);
- items.Select(i => i.Value).Should().BeEquivalentTo("dev", "staging", "production");
+ Assert.Equal(3, items.Length);
+ Assert.Equivalent(new[] { "dev", "staging", "production" }, items.Select(i => i.Value), strict: true);
}
[Fact]
@@ -359,9 +362,9 @@ await PostUpdateConfiguration([
var item = sections.Single(s => s.Key == "Complex").Arrays.Single(a => a.Key == "Items")
.Items.Single();
- item.Index.Should().Be(0);
- item.Fields.Single(f => f.Key == "Name").Value.Should().Be("First");
- item.Fields.Single(f => f.Key == "Priority").Value.Should().Be("10");
+ Assert.Equal(0, item.Index);
+ Assert.Equal("First", item.Fields.Single(f => f.Key == "Name").Value);
+ Assert.Equal("10", item.Fields.Single(f => f.Key == "Priority").Value);
}
[Fact]
@@ -377,8 +380,8 @@ await PostUpdateConfiguration([
var sections = await FetchSections();
var items = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags").Items;
- items.Should().ContainSingle(i => i.Index == 0);
- items.Should().NotContain(i => i.Index == 1);
+ Assert.Single(items, i => i.Index == 0);
+ Assert.DoesNotContain(items, i => i.Index == 1);
}
[Fact]
@@ -388,9 +391,10 @@ public async Task UpdateConfiguration_DeleteReturns200WithEmptyErrors()
var response = await PostUpdateConfiguration([], keysToDelete: ["Arrays:Tags:0"]);
- response.StatusCode.Should().Be(HttpStatusCode.OK);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var errors = await response.Content.ReadFromJsonAsync();
- errors.Should().BeEmpty();
+ Assert.NotNull(errors);
+ Assert.Empty(errors);
}
private Task PostGetConfiguration() =>
@@ -418,8 +422,7 @@ private async Task FetchSections()
public async Task GetConfiguration_Field_DefaultValueNullWithNoBaseConfig()
{
var sections = await FetchSections();
- sections.Single(s => s.Key == "Simple").Fields
- .Should().AllSatisfy(f => f.DefaultValue.Should().BeNull());
+ Assert.All(sections.Single(s => s.Key == "Simple").Fields, f => Assert.Null(f.DefaultValue));
}
[Fact]
@@ -429,7 +432,7 @@ public async Task GetConfiguration_ArrayItem_DefaultValueNullWithNoBaseConfig()
var sections = await FetchSections();
var item = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags").Items.Single();
- item.DefaultValue.Should().BeNull();
+ Assert.Null(item.DefaultValue);
}
[Fact]
@@ -439,7 +442,7 @@ public async Task GetConfiguration_ArrayItemAddedViaConfigWay_IsDeletable()
var sections = await FetchSections();
var item = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags").Items.Single();
- item.IsDeletable.Should().BeTrue();
+ Assert.True(item.IsDeletable);
}
private sealed record SectionDto(
@@ -526,7 +529,7 @@ public async Task GetConfiguration_WithBaseConfig_FieldDefaultValuePopulated()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.DefaultValue.Should().Be("DefaultName");
+ Assert.Equal("DefaultName", field.DefaultValue);
}
[Fact]
@@ -534,8 +537,8 @@ public async Task GetConfiguration_WithBaseConfig_ValueAndDefaultValueMatchIniti
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("DefaultName");
- field.DefaultValue.Should().Be("DefaultName");
+ Assert.Equal("DefaultName", field.Value);
+ Assert.Equal("DefaultName", field.DefaultValue);
}
[Fact]
@@ -545,8 +548,8 @@ public async Task UpdateConfiguration_Override_DefaultValueRemainsFromBaseConfig
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("Override");
- field.DefaultValue.Should().Be("DefaultName");
+ Assert.Equal("Override", field.Value);
+ Assert.Equal("DefaultName", field.DefaultValue);
}
[Fact]
@@ -557,8 +560,8 @@ public async Task UpdateConfiguration_DeleteOverride_ValueFallsBackToDefault()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Simple").Fields.Single(f => f.Key == "Name");
- field.Value.Should().Be("DefaultName");
- field.DefaultValue.Should().Be("DefaultName");
+ Assert.Equal("DefaultName", field.Value);
+ Assert.Equal("DefaultName", field.DefaultValue);
}
[Fact]
@@ -566,8 +569,8 @@ public async Task GetConfiguration_BaseConfigArrayItem_DefaultValuePopulated()
{
var sections = await FetchSections();
var items = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags").Items;
- items.Single(i => i.Index == 0).DefaultValue.Should().Be("base-tag");
- items.Single(i => i.Index == 1).DefaultValue.Should().Be("base-tag-2");
+ Assert.Equal("base-tag", items.Single(i => i.Index == 0).DefaultValue);
+ Assert.Equal("base-tag-2", items.Single(i => i.Index == 1).DefaultValue);
}
[Fact]
@@ -575,7 +578,7 @@ public async Task GetConfiguration_BaseConfigArrayItem_IsNotDeletable()
{
var sections = await FetchSections();
var items = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags").Items;
- items.Should().AllSatisfy(i => i.IsDeletable.Should().BeFalse());
+ Assert.All(items, i => Assert.False(i.IsDeletable));
}
[Fact]
@@ -586,8 +589,8 @@ public async Task UpdateConfiguration_OverrideBaseArrayItem_DefaultValueUnchange
var sections = await FetchSections();
var item = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags")
.Items.Single(i => i.Index == 0);
- item.Value.Should().Be("overridden");
- item.DefaultValue.Should().Be("base-tag");
+ Assert.Equal("overridden", item.Value);
+ Assert.Equal("base-tag", item.DefaultValue);
}
[Fact]
@@ -599,8 +602,8 @@ public async Task UpdateConfiguration_DeleteBaseArrayItemOverride_ValueFallsBack
var sections = await FetchSections();
var item = sections.Single(s => s.Key == "Arrays").Arrays.Single(a => a.Key == "Tags")
.Items.Single(i => i.Index == 0);
- item.Value.Should().Be("base-tag");
- item.DefaultValue.Should().Be("base-tag");
+ Assert.Equal("base-tag", item.Value);
+ Assert.Equal("base-tag", item.DefaultValue);
}
private Task PostGetConfiguration() =>
@@ -700,7 +703,7 @@ public async Task GetConfiguration_PasswordField_IsSensitiveTrue()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Password");
- field.IsSensitive.Should().BeTrue();
+ Assert.True(field.IsSensitive);
}
[Fact]
@@ -708,7 +711,7 @@ public async Task GetConfiguration_NonPasswordField_IsSensitiveFalse()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Username");
- field.IsSensitive.Should().BeFalse();
+ Assert.False(field.IsSensitive);
}
[Fact]
@@ -716,7 +719,7 @@ public async Task GetConfiguration_SensitiveField_InitiallyValueIsNull()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Password");
- field.Value.Should().BeNull();
+ Assert.Null(field.Value);
}
[Fact]
@@ -726,7 +729,7 @@ public async Task UpdateConfiguration_SensitiveField_ValueReturnedAsMask()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Password");
- field.Value.Should().Be("***");
+ Assert.Equal("***", field.Value);
}
[Fact]
@@ -736,7 +739,7 @@ public async Task UpdateConfiguration_SensitiveField_ActualValueNeverExposed()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "ApiKey");
- field.Value.Should().NotBe("real-key");
+ Assert.NotEqual("real-key", field.Value);
}
[Fact]
@@ -747,7 +750,7 @@ public async Task UpdateConfiguration_SensitiveField_CanBeOverwritten()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Password");
- field.Value.Should().Be("***");
+ Assert.Equal("***", field.Value);
}
[Fact]
@@ -758,7 +761,7 @@ public async Task UpdateConfiguration_SensitiveField_DeletedValueBecomesNull()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Password");
- field.Value.Should().BeNull();
+ Assert.Null(field.Value);
}
[Fact]
@@ -766,7 +769,7 @@ public async Task GetConfiguration_NestedSensitiveField_IsSensitiveTrue()
{
var sections = await FetchSections();
var creds = sections.Single(s => s.Key == "Nested").Sections.Single(s => s.Key == "Credentials");
- creds.Fields.Single(f => f.Key == "Secret").IsSensitive.Should().BeTrue();
+ Assert.True(creds.Fields.Single(f => f.Key == "Secret").IsSensitive);
}
[Fact]
@@ -776,7 +779,7 @@ public async Task UpdateConfiguration_NestedSensitiveField_ValueReturnedAsMask()
var sections = await FetchSections();
var creds = sections.Single(s => s.Key == "Nested").Sections.Single(s => s.Key == "Credentials");
- creds.Fields.Single(f => f.Key == "Secret").Value.Should().Be("***");
+ Assert.Equal("***", creds.Fields.Single(f => f.Key == "Secret").Value);
}
[Fact]
@@ -784,7 +787,7 @@ public async Task GetConfiguration_SensitiveField_InitiallyHasOverrideFalse()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Password");
- field.HasOverride.Should().BeFalse();
+ Assert.False(field.HasOverride);
}
[Fact]
@@ -794,7 +797,7 @@ public async Task UpdateConfiguration_SensitiveField_HasOverrideTrueAfterSave()
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Password");
- field.HasOverride.Should().BeTrue();
+ Assert.True(field.HasOverride);
}
[Fact]
@@ -805,7 +808,7 @@ public async Task UpdateConfiguration_SensitiveField_HasOverrideFalseAfterDelete
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Password");
- field.HasOverride.Should().BeFalse();
+ Assert.False(field.HasOverride);
}
[Fact]
@@ -813,7 +816,7 @@ public async Task GetConfiguration_NonSensitiveField_InitiallyHasOverrideFalse()
{
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Username");
- field.HasOverride.Should().BeFalse();
+ Assert.False(field.HasOverride);
}
[Fact]
@@ -823,7 +826,7 @@ public async Task UpdateConfiguration_NonSensitiveField_HasOverrideTrueAfterSave
var sections = await FetchSections();
var field = sections.Single(s => s.Key == "Sensitive").Fields.Single(f => f.Key == "Username");
- field.HasOverride.Should().BeTrue();
+ Assert.True(field.HasOverride);
}
private Task PostGetConfiguration() =>
diff --git a/src/ConfigWay.Tests/Unit/ConfigurationBuilderTests.cs b/src/ConfigWay.Tests/Unit/ConfigurationBuilderTests.cs
index 9562147..eeffb5d 100644
--- a/src/ConfigWay.Tests/Unit/ConfigurationBuilderTests.cs
+++ b/src/ConfigWay.Tests/Unit/ConfigurationBuilderTests.cs
@@ -1,4 +1,3 @@
-using FluentAssertions;
using Microsoft.AspNetCore.Builder;
using Xunit;
@@ -21,7 +20,7 @@ public void AddOptions_WithoutExplicitKey_DerivesKeyFromTypeName(Type type, stri
method.Invoke(builder, [null]);
var config = builder.Build();
- config.Options.Should().Contain(o => o.Key == expectedKey);
+ Assert.Contains(config.Options, o => o.Key == expectedKey);
}
[Fact]
@@ -31,7 +30,7 @@ public void AddOptions_WithExplicitKey_UsesProvidedKeyVerbatim()
builder.AddOptions("MyCustomKey");
var config = builder.Build();
- config.Options.Should().ContainSingle(o => o.Key == "MyCustomKey");
+ Assert.Single(config.Options, o => o.Key == "MyCustomKey");
}
[Fact]
@@ -42,8 +41,8 @@ public void AddOptions_CalledTwice_BothOptionsPresent()
builder.AddOptions("Second");
var config = builder.Build();
- config.Options.Should().HaveCount(2);
- config.Options.Select(o => o.Key).Should().BeEquivalentTo("First", "Second");
+ Assert.Equal(2, config.Options.Count);
+ Assert.Equivalent(new[] { "First", "Second" }, config.Options.Select(o => o.Key), strict: true);
}
[Fact]
@@ -53,7 +52,7 @@ public void AddOptions_StoresCorrectType()
builder.AddOptions("Simple");
var config = builder.Build();
- config.Options.Single(o => o.Key == "Simple").Type.Should().Be(typeof(SimpleOptions));
+ Assert.Equal(typeof(SimpleOptions), config.Options.Single(o => o.Key == "Simple").Type);
}
[Fact]
@@ -62,7 +61,7 @@ public void Build_WithDefaultStore_UsesInMemoryStore()
var builder = CreateBuilder();
var config = builder.Build();
- config.Store.Should().NotBeNull();
+ Assert.NotNull(config.Store);
}
private static ConfigurationBuilder CreateBuilder()
diff --git a/src/ConfigWay.Tests/Unit/ConfigurationProviderTests.cs b/src/ConfigWay.Tests/Unit/ConfigurationProviderTests.cs
index 29975dd..7736d42 100644
--- a/src/ConfigWay.Tests/Unit/ConfigurationProviderTests.cs
+++ b/src/ConfigWay.Tests/Unit/ConfigurationProviderTests.cs
@@ -1,4 +1,3 @@
-using FluentAssertions;
using Kododo.ConfigWay.Core.Configuration;
using Kododo.ConfigWay.Core.Model;
using Kododo.ConfigWay.Core.Store;
@@ -24,12 +23,12 @@ public void Load_IncludesOnlyKeysRegisteredForKnownOptions()
provider.Load();
- provider.TryGet("Simple:Name", out var name).Should().BeTrue();
- provider.TryGet("Simple:Value", out var value).Should().BeTrue();
- name.Should().Be("Alice");
- value.Should().Be("42");
+ Assert.True(provider.TryGet("Simple:Name", out var name));
+ Assert.True(provider.TryGet("Simple:Value", out var value));
+ Assert.Equal("Alice", name);
+ Assert.Equal("42", value);
- provider.TryGet("Unknown:Key", out _).Should().BeFalse();
+ Assert.False(provider.TryGet("Unknown:Key", out _));
}
[Fact]
@@ -41,8 +40,8 @@ public void Load_IsCaseInsensitive()
var provider = CreateProvider(store, new CoreOptions("Simple", typeof(SimpleOptions)));
provider.Load();
- provider.TryGet("simple:name", out var value).Should().BeTrue();
- value.Should().Be("Alice");
+ Assert.True(provider.TryGet("simple:name", out var value));
+ Assert.Equal("Alice", value);
}
[Fact]
@@ -54,8 +53,8 @@ public void Load_IncludesNullValues()
var provider = CreateProvider(store, new CoreOptions("Simple", typeof(SimpleOptions)));
provider.Load();
- provider.TryGet("Simple:Name", out var value).Should().BeTrue();
- value.Should().BeNull();
+ Assert.True(provider.TryGet("Simple:Name", out var value));
+ Assert.Null(value);
}
[Fact]
@@ -70,10 +69,10 @@ public void Load_ForNestedType_CollectsDeepKeys()
var provider = CreateProvider(store, new CoreOptions("Root", typeof(NestedOptions)));
provider.Load();
- provider.TryGet("Root:TopLevel", out var top).Should().BeTrue();
- provider.TryGet("Root:Child:ChildProp", out var child).Should().BeTrue();
- top.Should().Be("top");
- child.Should().Be("child");
+ Assert.True(provider.TryGet("Root:TopLevel", out var top));
+ Assert.True(provider.TryGet("Root:Child:ChildProp", out var child));
+ Assert.Equal("top", top);
+ Assert.Equal("child", child);
}
[Fact]
@@ -85,7 +84,7 @@ public void Load_IgnoresReadOnlyProperties()
var provider = CreateProvider(store, new CoreOptions("Opt", typeof(ReadOnlyPropOptions)));
provider.Load();
- provider.TryGet("Opt:ReadOnly", out _).Should().BeFalse();
+ Assert.False(provider.TryGet("Opt:ReadOnly", out _));
}
[Fact]
@@ -101,7 +100,7 @@ public async Task ReloadAsync_UpdatesData()
await ((IConfigurationEditor)provider).ReloadAllAsync(CancellationToken.None);
provider.TryGet("Simple:Name", out var value);
- value.Should().Be("After");
+ Assert.Equal("After", value);
}
[Fact]
@@ -119,7 +118,7 @@ public async Task ReloadAsync_FiresChangeToken()
await ((IConfigurationEditor)provider).ReloadAllAsync(CancellationToken.None);
- changed.Should().BeTrue();
+ Assert.True(changed);
}
private static ConfigurationProvider CreateProvider(IStore store, params CoreOptions[] options)
diff --git a/src/ConfigWay.Tests/Unit/GetConfigurationHandlerTests.cs b/src/ConfigWay.Tests/Unit/GetConfigurationHandlerTests.cs
index cd9e218..3130ee1 100644
--- a/src/ConfigWay.Tests/Unit/GetConfigurationHandlerTests.cs
+++ b/src/ConfigWay.Tests/Unit/GetConfigurationHandlerTests.cs
@@ -1,4 +1,3 @@
-using FluentAssertions;
using Kododo.ConfigWay.Core.Configuration;
using Kododo.ConfigWay.Core.Store;
using Kododo.ConfigWay.UI.API.GetConfiguration;
@@ -20,10 +19,10 @@ public async Task Handle_FlatType_ProducesFieldsOnly()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- var section = sections.Should().ContainSingle().Subject;
- section.Fields.Should().HaveCount(2);
- section.Sections.Should().BeEmpty();
- section.Arrays.Should().BeEmpty();
+ var section = Assert.Single(sections);
+ Assert.Equal(2, section.Fields.Length);
+ Assert.Empty(section.Sections);
+ Assert.Empty(section.Arrays);
}
[Fact]
@@ -34,8 +33,8 @@ public async Task Handle_NestedType_ProducesSubSection()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var root = sections.Single();
- root.Fields.Should().ContainSingle(f => f.Key == "TopLevel");
- root.Sections.Should().ContainSingle(s => s.Key == "Child");
+ Assert.Single(root.Fields, f => f.Key == "TopLevel");
+ Assert.Single(root.Sections, s => s.Key == "Child");
}
[Fact]
@@ -47,8 +46,8 @@ public async Task Handle_MultipleRegisteredOptions_ReturnsMultipleSections()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Should().HaveCount(2);
- sections.Select(s => s.Key).Should().BeEquivalentTo("Simple", "Nested");
+ Assert.Equal(2, sections.Length);
+ Assert.Equivalent(new[] { "Simple", "Nested" }, sections.Select(s => s.Key), strict: true);
}
[Fact]
@@ -62,9 +61,9 @@ public async Task Handle_GeneratesCorrectNestedKeys()
var child = root.Sections.Single();
var childProp = child.Fields.Single();
- root.Key.Should().Be("Root");
- child.Key.Should().Be("Child");
- childProp.Key.Should().Be("ChildProp");
+ Assert.Equal("Root", root.Key);
+ Assert.Equal("Child", child.Key);
+ Assert.Equal("ChildProp", childProp.Key);
}
[Fact]
@@ -76,9 +75,7 @@ public async Task Handle_FillsValueFromAppConfiguration()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields
- .Single(f => f.Key == "Name").Value
- .Should().Be("Alice");
+ Assert.Equal("Alice", sections.Single().Fields.Single(f => f.Key == "Name").Value);
}
[Fact]
@@ -88,9 +85,7 @@ public async Task Handle_MissingKeyInAppConfiguration_ValueIsNull()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields
- .Single(f => f.Key == "Name").Value
- .Should().BeNull();
+ Assert.Null(sections.Single().Fields.Single(f => f.Key == "Name").Value);
}
[Fact]
@@ -101,7 +96,7 @@ public async Task Handle_WithoutDisplayAttribute_UsesPropNameAsLabel()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var field = sections.Single().Fields.Single(f => f.Key == "Name");
- field.Name.Should().Be("Name");
+ Assert.Equal("Name", field.Name);
}
[Fact]
@@ -112,7 +107,7 @@ public async Task Handle_WithDisplayNameOnProperty_UsesDisplayName()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var field = sections.Single().Fields.Single(f => f.Key == "Field");
- field.Name.Should().Be("Custom Field");
+ Assert.Equal("Custom Field", field.Name);
}
[Fact]
@@ -122,7 +117,7 @@ public async Task Handle_WithDisplayNameOnClass_UsesSectionDisplayName()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Name.Should().Be("Custom Section Name");
+ Assert.Equal("Custom Section Name", sections.Single().Name);
}
[Fact]
@@ -132,7 +127,7 @@ public async Task Handle_WithoutDisplayNameOnClass_UsesKeyAsSectionName()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Name.Should().Be("Simple");
+ Assert.Equal("Simple", sections.Single().Name);
}
[Fact]
@@ -143,7 +138,7 @@ public async Task Handle_WithDisplayNameOnNestedType_PropagatesName()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var nested = sections.Single().Sections.Single();
- nested.Name.Should().Be("Nested Section");
+ Assert.Equal("Nested Section", nested.Name);
}
[Fact]
@@ -154,7 +149,7 @@ public async Task Handle_WithDisplayDescriptionOnProperty_PopulatesFieldDescript
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var field = sections.Single().Fields.Single(f => f.Key == "Field");
- field.Description.Should().Be("Field description");
+ Assert.Equal("Field description", field.Description);
}
[Fact]
@@ -164,7 +159,7 @@ public async Task Handle_WithDisplayDescriptionOnClass_PopulatesSectionDescripti
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Description.Should().Be("Section description");
+ Assert.Equal("Section description", sections.Single().Description);
}
[Fact]
@@ -174,8 +169,8 @@ public async Task Handle_WithoutDisplayDescription_DescriptionIsNull()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Should().AllSatisfy(f => f.Description.Should().BeNull());
- sections.Single().Description.Should().BeNull();
+ Assert.All(sections.Single().Fields, f => Assert.Null(f.Description));
+ Assert.Null(sections.Single().Description);
}
[Fact]
@@ -183,8 +178,9 @@ public async Task Handle_StringProperty_MapsToStringType()
{
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Label").Type
- .Should().Be(Kododo.ConfigWay.UI.DTO.FieldType.String);
+ Assert.Equal(
+ Kododo.ConfigWay.UI.DTO.FieldType.String,
+ sections.Single().Fields.Single(f => f.Key == "Label").Type);
}
[Fact]
@@ -192,8 +188,9 @@ public async Task Handle_BoolProperty_MapsToBoolType()
{
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Enabled").Type
- .Should().Be(Kododo.ConfigWay.UI.DTO.FieldType.Bool);
+ Assert.Equal(
+ Kododo.ConfigWay.UI.DTO.FieldType.Bool,
+ sections.Single().Fields.Single(f => f.Key == "Enabled").Type);
}
[Fact]
@@ -201,8 +198,9 @@ public async Task Handle_NullableBoolProperty_MapsToBoolType()
{
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Optional").Type
- .Should().Be(Kododo.ConfigWay.UI.DTO.FieldType.Bool);
+ Assert.Equal(
+ Kododo.ConfigWay.UI.DTO.FieldType.Bool,
+ sections.Single().Fields.Single(f => f.Key == "Optional").Type);
}
[Fact]
@@ -210,8 +208,9 @@ public async Task Handle_IntProperty_MapsToNumberType()
{
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Count").Type
- .Should().Be(Kododo.ConfigWay.UI.DTO.FieldType.Number);
+ Assert.Equal(
+ Kododo.ConfigWay.UI.DTO.FieldType.Number,
+ sections.Single().Fields.Single(f => f.Key == "Count").Type);
}
[Fact]
@@ -219,8 +218,9 @@ public async Task Handle_EnumProperty_MapsToEnumType()
{
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Level").Type
- .Should().Be(Kododo.ConfigWay.UI.DTO.FieldType.Enum);
+ Assert.Equal(
+ Kododo.ConfigWay.UI.DTO.FieldType.Enum,
+ sections.Single().Fields.Single(f => f.Key == "Level").Type);
}
[Fact]
@@ -228,9 +228,7 @@ public async Task Handle_NonEnumFields_HaveNullOptions()
{
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields
- .Where(f => f.Key != "Level")
- .Should().AllSatisfy(f => f.Options.Should().BeNull());
+ Assert.All(sections.Single().Fields.Where(f => f.Key != "Level"), f => Assert.Null(f.Options));
}
[Fact]
@@ -239,8 +237,8 @@ public async Task Handle_EnumField_PopulatesAllMemberValues()
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var options = sections.Single().Fields.Single(f => f.Key == "Level").Options;
- options.Should().NotBeNull();
- options!.Select(o => o.Value).Should().BeEquivalentTo("Low", "Medium", "High");
+ Assert.NotNull(options);
+ Assert.Equivalent(new[] { "Low", "Medium", "High" }, options!.Select(o => o.Value), strict: true);
}
[Fact]
@@ -249,8 +247,8 @@ public async Task Handle_EnumField_DisplayAttributeOnMember_UsesDisplayName()
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var options = sections.Single().Fields.Single(f => f.Key == "Level").Options!;
- options.Single(o => o.Value == "Low").Label.Should().Be("Low priority");
- options.Single(o => o.Value == "High").Label.Should().Be("High priority");
+ Assert.Equal("Low priority", options.Single(o => o.Value == "Low").Label);
+ Assert.Equal("High priority", options.Single(o => o.Value == "High").Label);
}
[Fact]
@@ -259,7 +257,7 @@ public async Task Handle_EnumField_MemberWithoutDisplayAttribute_UsesMemberName(
var handler = CreateHandler(new CoreOptions("T", typeof(TypedOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var options = sections.Single().Fields.Single(f => f.Key == "Level").Options!;
- options.Single(o => o.Value == "Medium").Label.Should().Be("Medium");
+ Assert.Equal("Medium", options.Single(o => o.Value == "Medium").Label);
}
[Fact]
@@ -269,8 +267,8 @@ public async Task Handle_SimpleStringArray_AppearsInArraysNotFields()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var section = sections.Single();
- section.Arrays.Should().ContainSingle(a => a.Key == "Tags");
- section.Fields.Should().NotContain(f => f.Key == "Tags");
+ Assert.Single(section.Arrays, a => a.Key == "Tags");
+ Assert.DoesNotContain(section.Fields, f => f.Key == "Tags");
}
[Fact]
@@ -279,8 +277,7 @@ public async Task Handle_SimpleStringArray_IsSimpleTrue()
var handler = CreateHandler(new CoreOptions("A", typeof(SimpleArrayOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Arrays.Single(a => a.Key == "Tags").IsSimple
- .Should().BeTrue();
+ Assert.True(sections.Single().Arrays.Single(a => a.Key == "Tags").IsSimple);
}
[Fact]
@@ -290,7 +287,7 @@ public async Task Handle_SimpleStringArray_TemplateHasStringType()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var template = sections.Single().Arrays.Single(a => a.Key == "Tags").Template;
- template.Type.Should().Be(Kododo.ConfigWay.UI.DTO.FieldType.String);
+ Assert.Equal(Kododo.ConfigWay.UI.DTO.FieldType.String, template.Type);
}
[Fact]
@@ -300,7 +297,7 @@ public async Task Handle_SimpleIntArray_TemplateHasNumberType()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var template = sections.Single().Arrays.Single(a => a.Key == "Ports").Template;
- template.Type.Should().Be(Kododo.ConfigWay.UI.DTO.FieldType.Number);
+ Assert.Equal(Kododo.ConfigWay.UI.DTO.FieldType.Number, template.Type);
}
[Fact]
@@ -309,8 +306,7 @@ public async Task Handle_ComplexArray_IsSimpleFalse()
var handler = CreateHandler(new CoreOptions("C", typeof(ComplexArrayOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Arrays.Single(a => a.Key == "Items").IsSimple
- .Should().BeFalse();
+ Assert.False(sections.Single().Arrays.Single(a => a.Key == "Items").IsSimple);
}
[Fact]
@@ -320,8 +316,8 @@ public async Task Handle_ComplexArray_TemplateHasFields()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var template = sections.Single().Arrays.Single(a => a.Key == "Items").Template;
- template.Fields.Should().NotBeEmpty();
- template.Fields.Select(f => f.Key).Should().BeEquivalentTo("Name", "Priority", "Category");
+ Assert.NotEmpty(template.Fields);
+ Assert.Equivalent(new[] { "Name", "Priority", "Category" }, template.Fields.Select(f => f.Key), strict: true);
}
[Fact]
@@ -332,8 +328,8 @@ public async Task Handle_ComplexArray_TemplateEnumField_HasOptions()
var template = sections.Single().Arrays.Single(a => a.Key == "Items").Template;
var categoryField = template.Fields.Single(f => f.Key == "Category");
- categoryField.Options.Should().NotBeNull();
- categoryField.Options!.Select(o => o.Value).Should().BeEquivalentTo("Primary", "Secondary");
+ Assert.NotNull(categoryField.Options);
+ Assert.Equivalent(new[] { "Primary", "Secondary" }, categoryField.Options!.Select(o => o.Value), strict: true);
}
[Fact]
@@ -342,8 +338,7 @@ public async Task Handle_ArrayWithNoItemsInConfig_HasEmptyItems()
var handler = CreateHandler(new CoreOptions("A", typeof(SimpleArrayOptions)));
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Arrays.Single(a => a.Key == "Tags").Items
- .Should().BeEmpty();
+ Assert.Empty(sections.Single().Arrays.Single(a => a.Key == "Tags").Items);
}
[Fact]
@@ -360,8 +355,7 @@ public async Task Handle_ArrayWithItemsInConfig_DetectsIndices()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Arrays.Single(a => a.Key == "Tags").Items
- .Should().HaveCount(3);
+ Assert.Equal(3, sections.Single().Arrays.Single(a => a.Key == "Tags").Items.Length);
}
[Fact]
@@ -374,8 +368,8 @@ public async Task Handle_ArrayItemFromConfig_HasCorrectValue()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var items = sections.Single().Arrays.Single(a => a.Key == "Tags").Items;
- items.Single(i => i.Index == 0).Value.Should().Be("hello");
- items.Single(i => i.Index == 1).Value.Should().Be("world");
+ Assert.Equal("hello", items.Single(i => i.Index == 0).Value);
+ Assert.Equal("world", items.Single(i => i.Index == 1).Value);
}
[Fact]
@@ -387,9 +381,7 @@ public async Task Handle_ArrayItemFromBaseConfig_IsNotDeletable()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Arrays.Single(a => a.Key == "Tags")
- .Items.Single().IsDeletable
- .Should().BeFalse();
+ Assert.False(sections.Single().Arrays.Single(a => a.Key == "Tags").Items.Single().IsDeletable);
}
[Fact]
@@ -406,8 +398,8 @@ public async Task Handle_ComplexArrayItemFromConfig_HasFields()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var item = sections.Single().Arrays.Single(a => a.Key == "Items").Items.Single();
- item.Fields.Should().NotBeEmpty();
- item.Fields.Single(f => f.Key == "Name").Value.Should().Be("First");
+ Assert.NotEmpty(item.Fields);
+ Assert.Equal("First", item.Fields.Single(f => f.Key == "Name").Value);
}
[Fact]
@@ -417,9 +409,7 @@ public async Task Handle_Field_DefaultValueNullWhenNotInBaseConfig()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields
- .Single(f => f.Key == "Name").DefaultValue
- .Should().BeNull();
+ Assert.Null(sections.Single().Fields.Single(f => f.Key == "Name").DefaultValue);
}
[Fact]
@@ -431,9 +421,7 @@ public async Task Handle_Field_DefaultValuePopulatedFromBaseConfig()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields
- .Single(f => f.Key == "Name").DefaultValue
- .Should().Be("Alice");
+ Assert.Equal("Alice", sections.Single().Fields.Single(f => f.Key == "Name").DefaultValue);
}
[Fact]
@@ -446,8 +434,7 @@ public async Task Handle_NestedField_DefaultValuePopulatedFromBaseConfig()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var child = sections.Single().Sections.Single();
- child.Fields.Single(f => f.Key == "ChildProp").DefaultValue
- .Should().Be("deep-default");
+ Assert.Equal("deep-default", child.Fields.Single(f => f.Key == "ChildProp").DefaultValue);
}
[Fact]
@@ -460,8 +447,8 @@ public async Task Handle_SimpleArrayItem_DefaultValueFromBaseConfig()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var items = sections.Single().Arrays.Single(a => a.Key == "Tags").Items;
- items.Single(i => i.Index == 0).DefaultValue.Should().Be("alpha");
- items.Single(i => i.Index == 1).DefaultValue.Should().Be("beta");
+ Assert.Equal("alpha", items.Single(i => i.Index == 0).DefaultValue);
+ Assert.Equal("beta", items.Single(i => i.Index == 1).DefaultValue);
}
[Fact]
@@ -478,7 +465,7 @@ public async Task Handle_ComplexArrayItem_DefaultValueIsNull()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var item = sections.Single().Arrays.Single(a => a.Key == "Items").Items.Single();
- item.DefaultValue.Should().BeNull();
+ Assert.Null(item.DefaultValue);
}
[Fact]
@@ -489,7 +476,7 @@ public async Task Handle_ArrayTemplate_DefaultValueIsNull()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var template = sections.Single().Arrays.Single(a => a.Key == "Tags").Template;
- template.DefaultValue.Should().BeNull();
+ Assert.Null(template.DefaultValue);
}
[Fact]
@@ -506,8 +493,8 @@ public async Task Handle_ComplexArrayItemField_DefaultValueFromBaseConfig()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var item = sections.Single().Arrays.Single(a => a.Key == "Items").Items.Single();
- item.Fields.Single(f => f.Key == "Name").DefaultValue.Should().Be("First");
- item.Fields.Single(f => f.Key == "Priority").DefaultValue.Should().Be("5");
+ Assert.Equal("First", item.Fields.Single(f => f.Key == "Name").DefaultValue);
+ Assert.Equal("5", item.Fields.Single(f => f.Key == "Priority").DefaultValue);
}
[Fact]
@@ -517,8 +504,7 @@ public async Task Handle_NonPasswordProperty_IsSensitiveFalse()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Username").IsSensitive
- .Should().BeFalse();
+ Assert.False(sections.Single().Fields.Single(f => f.Key == "Username").IsSensitive);
}
[Fact]
@@ -528,8 +514,7 @@ public async Task Handle_PasswordProperty_IsSensitiveTrue()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Password").IsSensitive
- .Should().BeTrue();
+ Assert.True(sections.Single().Fields.Single(f => f.Key == "Password").IsSensitive);
}
[Fact]
@@ -539,8 +524,7 @@ public async Task Handle_SensitiveField_NoStoredValue_ValueIsNull()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Password").Value
- .Should().BeNull();
+ Assert.Null(sections.Single().Fields.Single(f => f.Key == "Password").Value);
}
[Fact]
@@ -552,8 +536,7 @@ public async Task Handle_SensitiveField_WithStoredValue_ValueIsMasked()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Password").Value
- .Should().Be("***");
+ Assert.Equal("***", sections.Single().Fields.Single(f => f.Key == "Password").Value);
}
[Fact]
@@ -566,7 +549,7 @@ public async Task Handle_SensitiveField_ActualValueNeverReturned()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var field = sections.Single().Fields.Single(f => f.Key == "ApiKey");
- field.Value.Should().NotBe("my-actual-key");
+ Assert.NotEqual("my-actual-key", field.Value);
}
[Fact]
@@ -578,8 +561,7 @@ public async Task Handle_SensitiveField_WithDefaultValue_DefaultValueIsMasked()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Password").DefaultValue
- .Should().Be("***");
+ Assert.Equal("***", sections.Single().Fields.Single(f => f.Key == "Password").DefaultValue);
}
[Fact]
@@ -589,8 +571,7 @@ public async Task Handle_SensitiveField_NoDefaultValue_DefaultValueIsNull()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Password").DefaultValue
- .Should().BeNull();
+ Assert.Null(sections.Single().Fields.Single(f => f.Key == "Password").DefaultValue);
}
[Fact]
@@ -601,8 +582,7 @@ public async Task Handle_NestedSensitiveField_IsSensitiveTrue()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
var creds = sections.Single().Sections.Single(s => s.Key == "Credentials");
- creds.Fields.Single(f => f.Key == "Secret").IsSensitive
- .Should().BeTrue();
+ Assert.True(creds.Fields.Single(f => f.Key == "Secret").IsSensitive);
}
[Fact]
@@ -612,8 +592,7 @@ public async Task Handle_SensitiveField_NoOverride_HasOverrideFalse()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Password").HasOverride
- .Should().BeFalse();
+ Assert.False(sections.Single().Fields.Single(f => f.Key == "Password").HasOverride);
}
[Fact]
@@ -623,8 +602,7 @@ public async Task Handle_NonSensitiveField_NoOverride_HasOverrideFalse()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Username").HasOverride
- .Should().BeFalse();
+ Assert.False(sections.Single().Fields.Single(f => f.Key == "Username").HasOverride);
}
[Fact]
@@ -636,8 +614,7 @@ public async Task Handle_Field_BaseConfigAndAppConfigMatch_HasOverrideFalse()
var sections = await handler.HandleAsync(new GetConfiguration(), default);
- sections.Single().Fields.Single(f => f.Key == "Username").HasOverride
- .Should().BeFalse();
+ Assert.False(sections.Single().Fields.Single(f => f.Key == "Username").HasOverride);
}
private GetConfigurationHandler CreateHandler(params CoreOptions[] options) =>
diff --git a/src/ConfigWay.Tests/Unit/InMemoryStoreTests.cs b/src/ConfigWay.Tests/Unit/InMemoryStoreTests.cs
index b3a7c25..fb7a317 100644
--- a/src/ConfigWay.Tests/Unit/InMemoryStoreTests.cs
+++ b/src/ConfigWay.Tests/Unit/InMemoryStoreTests.cs
@@ -1,4 +1,3 @@
-using FluentAssertions;
using Kododo.ConfigWay.Core.Model;
using Xunit;
@@ -15,7 +14,7 @@ public InMemoryStoreTests() =>
public async Task GetAll_WhenEmpty_ReturnsEmptyList()
{
var result = await _store.GetAllAsync();
- result.Should().BeEmpty();
+ Assert.Empty(result);
}
[Fact]
@@ -25,9 +24,9 @@ public async Task GetAll_AfterSet_ReturnsStoredSettings()
var result = await _store.GetAllAsync();
- result.Should().HaveCount(2);
- result.Should().Contain(s => s.Key == "Key1" && s.Value == "Value1");
- result.Should().Contain(s => s.Key == "Key2" && s.Value == "Value2");
+ Assert.Equal(2, result.Count);
+ Assert.Contains(result, s => s.Key == "Key1" && s.Value == "Value1");
+ Assert.Contains(result, s => s.Key == "Key2" && s.Value == "Value2");
}
[Fact]
@@ -38,8 +37,8 @@ public async Task Set_ExistingKey_OverwritesValue()
var result = await _store.GetAllAsync();
- result.Should().ContainSingle();
- result.Single().Value.Should().Be("NewValue");
+ Assert.Single(result);
+ Assert.Equal("NewValue", result.Single().Value);
}
[Fact]
@@ -50,7 +49,7 @@ public async Task Set_ExistingKey_DoesNotDuplicateRow()
await _store.SetAsync([new Setting("Key", "C")]);
var result = await _store.GetAllAsync();
- result.Should().ContainSingle(s => s.Key == "Key");
+ Assert.Single(result, s => s.Key == "Key");
}
[Fact]
@@ -59,7 +58,7 @@ public async Task Set_NullValue_StoredAndRetrievedAsNull()
await _store.SetAsync([new Setting("Key", null)]);
var result = await _store.GetAllAsync();
- result.Single(s => s.Key == "Key").Value.Should().BeNull();
+ Assert.Null(result.Single(s => s.Key == "Key").Value);
}
[Fact]
@@ -69,7 +68,7 @@ public async Task Set_NullThenNonNull_Overwrites()
await _store.SetAsync([new Setting("Key", "Value")]);
var result = await _store.GetAllAsync();
- result.Single(s => s.Key == "Key").Value.Should().Be("Value");
+ Assert.Equal("Value", result.Single(s => s.Key == "Key").Value);
}
[Fact]
@@ -82,6 +81,6 @@ public async Task Set_MultipleSettings_AllInserted()
await _store.SetAsync(settings);
var result = await _store.GetAllAsync();
- result.Should().HaveCount(5);
+ Assert.Equal(5, result.Count);
}
}
diff --git a/src/ConfigWay.Tests/Unit/UpdateConfigurationHandlerTests.cs b/src/ConfigWay.Tests/Unit/UpdateConfigurationHandlerTests.cs
index 5a74d68..8de3824 100644
--- a/src/ConfigWay.Tests/Unit/UpdateConfigurationHandlerTests.cs
+++ b/src/ConfigWay.Tests/Unit/UpdateConfigurationHandlerTests.cs
@@ -1,4 +1,3 @@
-using FluentAssertions;
using Kododo.ConfigWay.Core.Configuration;
using Kododo.ConfigWay.Core.Model;
using Kododo.ConfigWay.Core.Store;
@@ -33,7 +32,7 @@ public async Task HandleAsync_ValidSettings_ReturnsEmptyErrors()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -68,7 +67,7 @@ public async Task HandleAsync_NullValue_Accepted()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -80,7 +79,7 @@ public async Task HandleAsync_WhenValidatorFails_ReturnsErrors()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().ContainSingle(e => e == AlwaysFailValidator.ErrorMessage);
+ Assert.Single(errors, e => e == AlwaysFailValidator.ErrorMessage);
}
[Fact]
@@ -116,7 +115,7 @@ public async Task HandleAsync_ConditionalValidator_FailsWhenNameEmpty()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().ContainSingle(e => e == ConditionalValidator.ErrorMessage);
+ Assert.Single(errors, e => e == ConditionalValidator.ErrorMessage);
}
[Fact]
@@ -128,7 +127,7 @@ public async Task HandleAsync_ConditionalValidator_PassesWhenNameProvided()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -141,7 +140,7 @@ public async Task HandleAsync_SettingsForDifferentSection_DoesNotRunValidator()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Theory]
@@ -156,7 +155,7 @@ public async Task HandleAsync_BoolValue_Accepted(string value)
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -167,7 +166,7 @@ public async Task HandleAsync_InvalidBoolValue_ReturnsError()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().ContainSingle(e => e.Contains("T:Enabled"));
+ Assert.Single(errors, e => e.Contains("T:Enabled"));
}
[Fact]
@@ -178,7 +177,7 @@ public async Task HandleAsync_IntValue_Accepted()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -189,7 +188,7 @@ public async Task HandleAsync_InvalidIntValue_ReturnsError()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().ContainSingle(e => e.Contains("T:Count"));
+ Assert.Single(errors, e => e.Contains("T:Count"));
}
[Theory]
@@ -205,7 +204,7 @@ public async Task HandleAsync_EnumValue_Accepted(string value)
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -216,7 +215,7 @@ public async Task HandleAsync_InvalidEnumValue_ReturnsError()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().ContainSingle(e => e.Contains("T:Level"));
+ Assert.Single(errors, e => e.Contains("T:Level"));
}
[Fact]
@@ -227,7 +226,7 @@ public async Task HandleAsync_NestedProperty_ValidatesCorrectly()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -238,7 +237,7 @@ public async Task HandleAsync_UnknownProperty_ReturnsError()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().ContainSingle(e => e.Contains("Simple:DoesNotExist"));
+ Assert.Single(errors, e => e.Contains("Simple:DoesNotExist"));
}
[Fact]
@@ -249,7 +248,7 @@ public async Task HandleAsync_SimpleArrayItemKey_AcceptedWithoutError()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -273,7 +272,7 @@ public async Task HandleAsync_ComplexArrayItemFieldKey_AcceptedWithoutError()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
@@ -289,7 +288,7 @@ public async Task HandleAsync_MultipleArrayItems_AllAccepted()
var errors = await handler.HandleAsync(new UpdateConfiguration(settings), default);
- errors.Should().BeEmpty();
+ Assert.Empty(errors);
}
[Fact]
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index 0f693b5..b12fb67 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -23,7 +23,6 @@
-