From 726a246a6d37124fdf7b77df18ebe7cd77a93c64 Mon Sep 17 00:00:00 2001 From: bfren Date: Wed, 28 Jan 2026 09:45:39 +0000 Subject: [PATCH 01/12] Moving Jeebs extensions tests to match project layout - #531 --- .../{_ => Extensions}/DateTimeExtensions/EndOfDay_Tests.cs | 0 .../{_ => Extensions}/DateTimeExtensions/FirstDayOfMonth_Tests.cs | 0 .../{_ => Extensions}/DateTimeExtensions/FirstDayOfWeek_Tests.cs | 0 .../{_ => Extensions}/DateTimeExtensions/LastDayOfMonth_Tests.cs | 0 .../{_ => Extensions}/DateTimeExtensions/LastDayOfWeek_Tests.cs | 0 .../{_ => Extensions}/DateTimeExtensions/StartOfDay_Tests.cs | 0 .../DateTimeExtensions/ToSortableString_Tests.cs | 0 .../DateTimeExtensions/ToStandardString_Tests.cs | 0 .../{_ => Extensions}/ResultExtensions/LogAsync_Tests.cs | 0 .../{_ => Extensions}/ResultExtensions/LogBoolAsync_Tests.cs | 0 .../{_ => Extensions}/ResultExtensions/LogBool_Tests.cs | 0 tests/Tests.Jeebs/{_ => Extensions}/ResultExtensions/Log_Tests.cs | 0 .../TypeExtensions/ImplementsGenericClass_Tests.cs | 0 .../TypeExtensions/ImplementsGenericInterface_Tests.cs | 0 .../{_ => Extensions}/TypeExtensions/Implements_Tests0.cs | 0 .../{_ => Extensions}/TypeExtensions/Implements_Tests1.cs | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename tests/Tests.Jeebs/{_ => Extensions}/DateTimeExtensions/EndOfDay_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/DateTimeExtensions/FirstDayOfMonth_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/DateTimeExtensions/FirstDayOfWeek_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/DateTimeExtensions/LastDayOfMonth_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/DateTimeExtensions/LastDayOfWeek_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/DateTimeExtensions/StartOfDay_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/DateTimeExtensions/ToSortableString_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/DateTimeExtensions/ToStandardString_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/ResultExtensions/LogAsync_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/ResultExtensions/LogBoolAsync_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/ResultExtensions/LogBool_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/ResultExtensions/Log_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/TypeExtensions/ImplementsGenericClass_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/TypeExtensions/ImplementsGenericInterface_Tests.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/TypeExtensions/Implements_Tests0.cs (100%) rename tests/Tests.Jeebs/{_ => Extensions}/TypeExtensions/Implements_Tests1.cs (100%) diff --git a/tests/Tests.Jeebs/_/DateTimeExtensions/EndOfDay_Tests.cs b/tests/Tests.Jeebs/Extensions/DateTimeExtensions/EndOfDay_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/DateTimeExtensions/EndOfDay_Tests.cs rename to tests/Tests.Jeebs/Extensions/DateTimeExtensions/EndOfDay_Tests.cs diff --git a/tests/Tests.Jeebs/_/DateTimeExtensions/FirstDayOfMonth_Tests.cs b/tests/Tests.Jeebs/Extensions/DateTimeExtensions/FirstDayOfMonth_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/DateTimeExtensions/FirstDayOfMonth_Tests.cs rename to tests/Tests.Jeebs/Extensions/DateTimeExtensions/FirstDayOfMonth_Tests.cs diff --git a/tests/Tests.Jeebs/_/DateTimeExtensions/FirstDayOfWeek_Tests.cs b/tests/Tests.Jeebs/Extensions/DateTimeExtensions/FirstDayOfWeek_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/DateTimeExtensions/FirstDayOfWeek_Tests.cs rename to tests/Tests.Jeebs/Extensions/DateTimeExtensions/FirstDayOfWeek_Tests.cs diff --git a/tests/Tests.Jeebs/_/DateTimeExtensions/LastDayOfMonth_Tests.cs b/tests/Tests.Jeebs/Extensions/DateTimeExtensions/LastDayOfMonth_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/DateTimeExtensions/LastDayOfMonth_Tests.cs rename to tests/Tests.Jeebs/Extensions/DateTimeExtensions/LastDayOfMonth_Tests.cs diff --git a/tests/Tests.Jeebs/_/DateTimeExtensions/LastDayOfWeek_Tests.cs b/tests/Tests.Jeebs/Extensions/DateTimeExtensions/LastDayOfWeek_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/DateTimeExtensions/LastDayOfWeek_Tests.cs rename to tests/Tests.Jeebs/Extensions/DateTimeExtensions/LastDayOfWeek_Tests.cs diff --git a/tests/Tests.Jeebs/_/DateTimeExtensions/StartOfDay_Tests.cs b/tests/Tests.Jeebs/Extensions/DateTimeExtensions/StartOfDay_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/DateTimeExtensions/StartOfDay_Tests.cs rename to tests/Tests.Jeebs/Extensions/DateTimeExtensions/StartOfDay_Tests.cs diff --git a/tests/Tests.Jeebs/_/DateTimeExtensions/ToSortableString_Tests.cs b/tests/Tests.Jeebs/Extensions/DateTimeExtensions/ToSortableString_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/DateTimeExtensions/ToSortableString_Tests.cs rename to tests/Tests.Jeebs/Extensions/DateTimeExtensions/ToSortableString_Tests.cs diff --git a/tests/Tests.Jeebs/_/DateTimeExtensions/ToStandardString_Tests.cs b/tests/Tests.Jeebs/Extensions/DateTimeExtensions/ToStandardString_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/DateTimeExtensions/ToStandardString_Tests.cs rename to tests/Tests.Jeebs/Extensions/DateTimeExtensions/ToStandardString_Tests.cs diff --git a/tests/Tests.Jeebs/_/ResultExtensions/LogAsync_Tests.cs b/tests/Tests.Jeebs/Extensions/ResultExtensions/LogAsync_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/ResultExtensions/LogAsync_Tests.cs rename to tests/Tests.Jeebs/Extensions/ResultExtensions/LogAsync_Tests.cs diff --git a/tests/Tests.Jeebs/_/ResultExtensions/LogBoolAsync_Tests.cs b/tests/Tests.Jeebs/Extensions/ResultExtensions/LogBoolAsync_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/ResultExtensions/LogBoolAsync_Tests.cs rename to tests/Tests.Jeebs/Extensions/ResultExtensions/LogBoolAsync_Tests.cs diff --git a/tests/Tests.Jeebs/_/ResultExtensions/LogBool_Tests.cs b/tests/Tests.Jeebs/Extensions/ResultExtensions/LogBool_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/ResultExtensions/LogBool_Tests.cs rename to tests/Tests.Jeebs/Extensions/ResultExtensions/LogBool_Tests.cs diff --git a/tests/Tests.Jeebs/_/ResultExtensions/Log_Tests.cs b/tests/Tests.Jeebs/Extensions/ResultExtensions/Log_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/ResultExtensions/Log_Tests.cs rename to tests/Tests.Jeebs/Extensions/ResultExtensions/Log_Tests.cs diff --git a/tests/Tests.Jeebs/_/TypeExtensions/ImplementsGenericClass_Tests.cs b/tests/Tests.Jeebs/Extensions/TypeExtensions/ImplementsGenericClass_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/TypeExtensions/ImplementsGenericClass_Tests.cs rename to tests/Tests.Jeebs/Extensions/TypeExtensions/ImplementsGenericClass_Tests.cs diff --git a/tests/Tests.Jeebs/_/TypeExtensions/ImplementsGenericInterface_Tests.cs b/tests/Tests.Jeebs/Extensions/TypeExtensions/ImplementsGenericInterface_Tests.cs similarity index 100% rename from tests/Tests.Jeebs/_/TypeExtensions/ImplementsGenericInterface_Tests.cs rename to tests/Tests.Jeebs/Extensions/TypeExtensions/ImplementsGenericInterface_Tests.cs diff --git a/tests/Tests.Jeebs/_/TypeExtensions/Implements_Tests0.cs b/tests/Tests.Jeebs/Extensions/TypeExtensions/Implements_Tests0.cs similarity index 100% rename from tests/Tests.Jeebs/_/TypeExtensions/Implements_Tests0.cs rename to tests/Tests.Jeebs/Extensions/TypeExtensions/Implements_Tests0.cs diff --git a/tests/Tests.Jeebs/_/TypeExtensions/Implements_Tests1.cs b/tests/Tests.Jeebs/Extensions/TypeExtensions/Implements_Tests1.cs similarity index 100% rename from tests/Tests.Jeebs/_/TypeExtensions/Implements_Tests1.cs rename to tests/Tests.Jeebs/Extensions/TypeExtensions/Implements_Tests1.cs From fdde59499818466fe0f8f87d396de10d1cba0069 Mon Sep 17 00:00:00 2001 From: bfren Date: Wed, 28 Jan 2026 10:19:05 +0000 Subject: [PATCH 02/12] Don't suggest primary constructors in tests - #531 --- tests/.editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/.editorconfig b/tests/.editorconfig index 47127de6c..ab2d01d94 100644 --- a/tests/.editorconfig +++ b/tests/.editorconfig @@ -39,6 +39,9 @@ dotnet_diagnostic.IDE0053.severity = none # IDE0058: Expression value is never used dotnet_diagnostic.IDE0058.severity = none +# IDE0290: Use primary constructor +dotnet_diagnostic.IDE0290.severity = none + # IDE1006: Naming Styles dotnet_diagnostic.IDE1006.severity = none From 1c8b46a41e6343ba9d61393cf04296c8211218b5 Mon Sep 17 00:00:00 2001 From: bfren Date: Wed, 28 Jan 2026 17:41:32 +0000 Subject: [PATCH 03/12] Using Record.Exception - #531 --- .../_/CompareExtensions/ToOperator_Tests.cs | 4 +- .../TypeHandlers/Json/Parse_Tests.cs | 8 ++-- .../_/CompareExtensions/ToOperator_Tests.cs | 4 +- .../_/CompareExtensions/ToOperator_Tests.cs | 4 +- .../_/CompareExtensions/ToOperator_Tests.cs | 4 +- .../QueryBuilderWithFrom/CheckTable_Tests.cs | 4 +- .../_/QueryBuilderWithFrom/Join_Tests.cs | 4 +- .../_/QueryBuilderWithFrom/Where_Tests.cs | 4 +- .../QueryPartsBuilderWithEntity/Map_Tests.cs | 5 +-- .../AssertCollection_Tests.cs | 12 +++--- .../AssertEqualJson_Tests.cs | 8 ++-- .../FluentQueryHelper/AssertEqual_Tests.cs | 4 +- .../FluentQueryHelper/AssertExecute_Tests.cs | 15 ++++--- .../AssertGenericArgument_Tests.cs | 16 ++++---- .../AssertMethodName_Tests.cs | 4 +- .../AssertPropertyExpression_Tests.cs | 8 ++-- .../FluentQueryHelper/AssertWhereIn_Tests.cs | 15 ++++--- .../AssertWhereNotIn_Tests.cs | 15 ++++--- .../FluentQueryHelper/AssertWhere_Tests.cs | 40 +++++++++++-------- .../Map/_/EntityMapper/Map_Tests.cs | 24 +++++------ .../TypeHandlers/Guid/Parse_Tests.cs | 4 +- .../TypeHandlers/Json/Parse_Tests.cs | 8 ++-- .../TypeHandlers/Boolean/SetValue_Tests.cs | 4 +- 23 files changed, 117 insertions(+), 101 deletions(-) diff --git a/tests/Tests.Jeebs.Data.Clients.MySql/_/CompareExtensions/ToOperator_Tests.cs b/tests/Tests.Jeebs.Data.Clients.MySql/_/CompareExtensions/ToOperator_Tests.cs index c2cababd1..8c204cc9b 100644 --- a/tests/Tests.Jeebs.Data.Clients.MySql/_/CompareExtensions/ToOperator_Tests.cs +++ b/tests/Tests.Jeebs.Data.Clients.MySql/_/CompareExtensions/ToOperator_Tests.cs @@ -135,9 +135,9 @@ public void Other_Throws_UnrecognisedSearchOperatorException(int input) var value = (Compare)input; // Act - var action = void () => value.ToOperator(); + var result = Record.Exception(() => value.ToOperator()); // Assert - Assert.Throws(action); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Clients.PostgreSql/TypeHandlers/Json/Parse_Tests.cs b/tests/Tests.Jeebs.Data.Clients.PostgreSql/TypeHandlers/Json/Parse_Tests.cs index b586c5220..540b7ed11 100644 --- a/tests/Tests.Jeebs.Data.Clients.PostgreSql/TypeHandlers/Json/Parse_Tests.cs +++ b/tests/Tests.Jeebs.Data.Clients.PostgreSql/TypeHandlers/Json/Parse_Tests.cs @@ -18,10 +18,10 @@ public void Null_Or_Whitespace_Throws_JsonException(string input) var handler = new JsonbTypeHandler(); // Act - var action = void () => handler.Parse(input); + var result = Record.Exception(() => handler.Parse(input)); // Assert - Assert.Throws(action); + Assert.IsType(result); } [Fact] @@ -32,10 +32,10 @@ public void InvalidJson_Throws_JsonException() var input = Rnd.Str; // Act - var action = void () => handler.Parse(input); + var result = Record.Exception(() => handler.Parse(input)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.IsType(ex.InnerException); } diff --git a/tests/Tests.Jeebs.Data.Clients.PostgreSql/_/CompareExtensions/ToOperator_Tests.cs b/tests/Tests.Jeebs.Data.Clients.PostgreSql/_/CompareExtensions/ToOperator_Tests.cs index 29f44a72b..b8b2ecc3d 100644 --- a/tests/Tests.Jeebs.Data.Clients.PostgreSql/_/CompareExtensions/ToOperator_Tests.cs +++ b/tests/Tests.Jeebs.Data.Clients.PostgreSql/_/CompareExtensions/ToOperator_Tests.cs @@ -135,9 +135,9 @@ public void Other_Throws_UnrecognisedSearchOperatorException(int input) var value = (Compare)input; // Act - var action = void () => value.ToOperator(); + var result = Record.Exception(() => value.ToOperator()); // Assert - Assert.Throws(action); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Clients.SqlServer/_/CompareExtensions/ToOperator_Tests.cs b/tests/Tests.Jeebs.Data.Clients.SqlServer/_/CompareExtensions/ToOperator_Tests.cs index b030b4a3a..408814f08 100644 --- a/tests/Tests.Jeebs.Data.Clients.SqlServer/_/CompareExtensions/ToOperator_Tests.cs +++ b/tests/Tests.Jeebs.Data.Clients.SqlServer/_/CompareExtensions/ToOperator_Tests.cs @@ -135,9 +135,9 @@ public void Other_Throws_UnrecognisedSearchOperatorException(int input) var value = (Compare)input; // Act - var action = void () => value.ToOperator(); + var result = Record.Exception(() => value.ToOperator()); // Assert - Assert.Throws(action); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Clients.Sqlite/_/CompareExtensions/ToOperator_Tests.cs b/tests/Tests.Jeebs.Data.Clients.Sqlite/_/CompareExtensions/ToOperator_Tests.cs index 7cd96fe9f..ea5c0df35 100644 --- a/tests/Tests.Jeebs.Data.Clients.Sqlite/_/CompareExtensions/ToOperator_Tests.cs +++ b/tests/Tests.Jeebs.Data.Clients.Sqlite/_/CompareExtensions/ToOperator_Tests.cs @@ -135,9 +135,9 @@ public void Other_Throws_UnrecognisedSearchOperatorException(int input) var value = (Compare)input; // Act - var action = void () => value.ToOperator(); + var result = Record.Exception(() => value.ToOperator()); // Assert - Assert.Throws(action); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/CheckTable_Tests.cs b/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/CheckTable_Tests.cs index 63761ab1d..86e8b7e0f 100644 --- a/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/CheckTable_Tests.cs +++ b/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/CheckTable_Tests.cs @@ -16,10 +16,10 @@ public void Table_Not_Added_Throws_Exception() var builder = new QueryBuilderWithFrom(table); // Act - var action = void () => builder.CheckTable>(); + var result = Record.Exception(() => builder.CheckTable>()); // Assert - Assert.Throws>(action); + Assert.IsType>(result); } [Fact] diff --git a/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/Join_Tests.cs b/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/Join_Tests.cs index 67397ab50..b4fb33f65 100644 --- a/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/Join_Tests.cs +++ b/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/Join_Tests.cs @@ -18,10 +18,10 @@ public void From_Table_Not_Added_Throws_JoinFromTableNotAddedException() var builder = new QueryBuilderWithFrom(table); // Act - var action = void () => builder.Join(QueryJoin.Inner, t => t.Foo, t => t.Foo); + var result = Record.Exception(() => builder.Join(QueryJoin.Inner, t => t.Foo, t => t.Foo)); // Assert - Assert.Throws>(action); + Assert.IsType>(result); } [Fact] diff --git a/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/Where_Tests.cs b/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/Where_Tests.cs index 47917b4b8..161af9b79 100644 --- a/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/Where_Tests.cs +++ b/tests/Tests.Jeebs.Data.Query/_/QueryBuilderWithFrom/Where_Tests.cs @@ -17,10 +17,10 @@ public void Table_Not_Added_Throws_WhereTableNotAddedException() var builder = new QueryBuilderWithFrom(table); // Act - var action = void () => builder.Where(t => t.Foo, Compare.Equal, Rnd.Str); + var result = Record.Exception(() => builder.Where(t => t.Foo, Compare.Equal, Rnd.Str)); // Assert - Assert.Throws>(action); + Assert.IsType>(result); } [Fact] diff --git a/tests/Tests.Jeebs.Data.Query/_/QueryPartsBuilderWithEntity/Map_Tests.cs b/tests/Tests.Jeebs.Data.Query/_/QueryPartsBuilderWithEntity/Map_Tests.cs index e50e1f61c..7acc03d05 100644 --- a/tests/Tests.Jeebs.Data.Query/_/QueryPartsBuilderWithEntity/Map_Tests.cs +++ b/tests/Tests.Jeebs.Data.Query/_/QueryPartsBuilderWithEntity/Map_Tests.cs @@ -1,7 +1,6 @@ // Jeebs Unit Tests // Copyright (c) bfren - licensed under https://mit.bfren.dev/2013 -using Jeebs.Data.Map; using Wrap.Exceptions; namespace Jeebs.Data.Query.QueryPartsBuilderWithEntity_Tests; @@ -29,9 +28,9 @@ public void Entity_Not_Mapped_Throws_MsgException_With_Msg() v.Mapper.GetTableMapFor().Returns(FailGen.Create()); // Act - var action = ITableMap () => builder.Map.Value; + var result = Record.Exception(() => builder.Map.Value); // Assert - Assert.Throws(action); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertCollection_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertCollection_Tests.cs index d0386231b..dd0493704 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertCollection_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertCollection_Tests.cs @@ -16,10 +16,10 @@ public void Collection_And_Inspectors_Different_Lengths__Throws_CollectionExcept var inspectors = Enumerable.Repeat((string _) => { }, Rnd.Int).ToArray(); // Act - var action = () => FluentQueryHelper.AssertCollection(collection, inspectors); + var result = Record.Exception(() => FluentQueryHelper.AssertCollection(collection, inspectors)); // Assert - Assert.Throws(action); + Assert.IsType(result); } [Fact] @@ -30,10 +30,10 @@ public void Inspector_Throws_FluentQueryHelperException__Catches_And_Rethrows() var inspectors = new Action[] { _ => throw new EqualTypeException() }; // Act - var action = () => FluentQueryHelper.AssertCollection(collection, inspectors); + var result = Record.Exception(() => FluentQueryHelper.AssertCollection(collection, inspectors)); // Assert - Assert.Throws(action); + Assert.IsType(result); } [Fact] @@ -44,9 +44,9 @@ public void Inspector_Throws_Exception__Catches_And_Throws_As_CollectionExceptio var inspectors = new Action[] { _ => throw new InvalidOperationException() }; // Act - var action = () => FluentQueryHelper.AssertCollection(collection, inspectors); + var result = Record.Exception(() => FluentQueryHelper.AssertCollection(collection, inspectors)); // Assert - Assert.Throws(action); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertEqualJson_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertEqualJson_Tests.cs index 57372a685..92c830212 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertEqualJson_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertEqualJson_Tests.cs @@ -31,10 +31,10 @@ public void Different_Property_Names__Equal_Values__Throws_EqualJsonException() var v1 = new { v1 = value }; // Act - var action = () => FluentQueryHelper.AssertEqualJson(v0, v1); + var result = Record.Exception(() => FluentQueryHelper.AssertEqualJson(v0, v1)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Equal($"Expected '{v0}' but value was '{v1}'.", ex.Message); } @@ -46,10 +46,10 @@ public void Same_Property_Names__Different_Values__Throws_EqualJsonException() var v1 = new { v1 = Rnd.Str }; // Act - var action = () => FluentQueryHelper.AssertEqualJson(v0, v1); + var result = Record.Exception(() => FluentQueryHelper.AssertEqualJson(v0, v1)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Equal($"Expected '{v0}' but value was '{v1}'.", ex.Message); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertEqual_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertEqual_Tests.cs index 87ef3f01b..632d48488 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertEqual_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertEqual_Tests.cs @@ -28,10 +28,10 @@ public void Not_Equal__Throws_EqualTypeException() var v1 = Rnd.Str; // Act - var action = () => FluentQueryHelper.AssertEqual(v0, v1); + var result = Record.Exception(() => FluentQueryHelper.AssertEqual(v0, v1)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Equal($"Expected '{v0}' but value was '{v1}'.", ex.Message); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertExecute_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertExecute_Tests.cs index 93e06b4f3..15bc28b15 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertExecute_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertExecute_Tests.cs @@ -44,12 +44,13 @@ public async Task Incorrect_Method__Throws_MethodNameException() // Arrange var fluent = Create(); await fluent.CountAsync(); + var action = (ICall c) => FluentQueryHelper.AssertExecute(c, x => x.Id, true); // Act - var action = (ICall c) => FluentQueryHelper.AssertExecute(c, x => x.Id, true); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -58,12 +59,13 @@ public async Task Incorrect_Generic_Argument__Throws_GenericArgumentException() // Arrange var fluent = Create(); await fluent.ExecuteAsync(x => x.Id); + var action = (ICall c) => FluentQueryHelper.AssertExecute(c, nameof(TestEntity.Id), false); // Act - var action = (ICall c) => FluentQueryHelper.AssertExecute(c, nameof(TestEntity.Id), false); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -72,11 +74,12 @@ public async Task Not_Property_Expression__Throws_PropertyExpressionException() // Arrange var fluent = Create(); await fluent.ExecuteAsync(nameof(TestEntity.Id)); + var action = (ICall c) => FluentQueryHelper.AssertExecute(c, x => x.Id, false); // Act - var action = (ICall c) => FluentQueryHelper.AssertExecute(c, x => x.Id, false); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertGenericArgument_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertGenericArgument_Tests.cs index ef7afcae0..86a6cef60 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertGenericArgument_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertGenericArgument_Tests.cs @@ -41,10 +41,10 @@ public void Incorrect_Type__Throws_GenericArgumentException() .Returns(method); // Act - var action = () => FluentQueryHelper.AssertGenericArgument(call); + var result = Record.Exception(() => FluentQueryHelper.AssertGenericArgument(call)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Contains($"Expected type '{typeof(Guid)}' but found '{typeof(string)}'.", ex.Message); } @@ -54,16 +54,16 @@ public void No_Generic_Arguments__Throws_GenericArgumentException() // Arrange var method = Substitute.ForPartsOf(); method.Configure().GetGenericArguments() - .Returns(Array.Empty()); + .Returns([]); var call = Substitute.For(); call.GetMethodInfo() .Returns(method); // Act - var action = () => FluentQueryHelper.AssertGenericArgument(call); + var result = Record.Exception(() => FluentQueryHelper.AssertGenericArgument(call)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Equal("Expected one generic argument but found none.", ex.Message); } @@ -74,16 +74,16 @@ public void Too_Many_Generic_Arguments__Throws_GenericArgumentException() var method = Substitute.ForPartsOf(); var args = Rnd.NumberF.GetInt32(2, 10); method.Configure().GetGenericArguments() - .Returns(Enumerable.Repeat(typeof(string), args).ToArray()); + .Returns([.. Enumerable.Repeat(typeof(string), args)]); var call = Substitute.For(); call.GetMethodInfo() .Returns(method); // Act - var action = () => FluentQueryHelper.AssertGenericArgument(call); + var result = Record.Exception(() => FluentQueryHelper.AssertGenericArgument(call)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Equal($"Expected one generic argument but found {args}.", ex.Message); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertMethodName_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertMethodName_Tests.cs index 3da3f2f9e..3e4dee68e 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertMethodName_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertMethodName_Tests.cs @@ -41,9 +41,9 @@ public void Not_Equal__Throws_MethodNameException() .Returns(method); // Act - var action = () => FluentQueryHelper.AssertMethodName(call, Rnd.Str); + var result = Record.Exception(() => FluentQueryHelper.AssertMethodName(call, Rnd.Str)); // Assert - Assert.Throws(action); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertPropertyExpression_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertPropertyExpression_Tests.cs index e26fc4d90..d68dbf624 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertPropertyExpression_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertPropertyExpression_Tests.cs @@ -28,10 +28,10 @@ public void Not_Expression__Throws_PropertyExpressionException() // Arrange // Act - var action = () => FluentQueryHelper.AssertPropertyExpression(Rnd.Str, Rnd.Str); + var result = Record.Exception(() => FluentQueryHelper.AssertPropertyExpression(Rnd.Str, Rnd.Str)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Equal($"Expected a property expression but received '{typeof(string)}'.", ex.Message); } @@ -43,10 +43,10 @@ public void Not_Equal__Throws_PropertyExpressionException() Expression> actual = x => x.Foo; // Act - var action = () => FluentQueryHelper.AssertPropertyExpression(expected, actual); + var result = Record.Exception(() => FluentQueryHelper.AssertPropertyExpression(expected, actual)); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Equal($"Expected property with name '{expected}' but received '{nameof(Test.Foo)}'.", ex.Message); } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhereIn_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhereIn_Tests.cs index c22769bc3..9793c46bb 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhereIn_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhereIn_Tests.cs @@ -29,12 +29,13 @@ public void Incorrect_Method__Throws_MethodNameException() // Arrange var fluent = Create(); fluent.Maximum(Rnd.ULng); + var action = (ICall c) => FluentQueryHelper.AssertWhereIn(c, x => x.Bar, [Rnd.Lng, Rnd.Lng]); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhereIn(c, x => x.Bar, [Rnd.Lng, Rnd.Lng]); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -44,12 +45,13 @@ public void Incorrect_Generic_Argument__Throws_GenericArgumentException() var fluent = Create(); var values = new[] { Rnd.Str, Rnd.Str }; fluent.WhereIn(x => x.Foo, values); + var action = (ICall c) => FluentQueryHelper.AssertWhereIn(c, x => x.Bar, [Rnd.Lng, Rnd.Lng]); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhereIn(c, x => x.Bar, [Rnd.Lng, Rnd.Lng]); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -59,11 +61,12 @@ public void Values_Not_Equal__Throws_EqualTypeException() var fluent = Create(); var values = new[] { Rnd.Str, Rnd.Str }; fluent.WhereIn(x => x.Foo, values); + var action = (ICall c) => FluentQueryHelper.AssertWhereIn(c, x => x.Foo, [Rnd.Str, Rnd.Str]); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhereIn(c, x => x.Foo, [Rnd.Str, Rnd.Str]); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhereNotIn_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhereNotIn_Tests.cs index b62ba21de..4ff2f3239 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhereNotIn_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhereNotIn_Tests.cs @@ -29,12 +29,13 @@ public void Incorrect_Method__Throws_MethodNameException() // Arrange var fluent = Create(); fluent.Maximum(Rnd.ULng); + var action = (ICall c) => FluentQueryHelper.AssertWhereNotIn(c, x => x.Bar, [Rnd.Lng, Rnd.Lng]); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhereNotIn(c, x => x.Bar, [Rnd.Lng, Rnd.Lng]); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -44,12 +45,13 @@ public void Incorrect_Generic_Argument__Throws_GenericArgumentException() var fluent = Create(); var values = new[] { Rnd.Str, Rnd.Str }; fluent.WhereNotIn(x => x.Foo, values); + var action = (ICall c) => FluentQueryHelper.AssertWhereNotIn(c, x => x.Bar, [Rnd.Lng, Rnd.Lng]); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhereNotIn(c, x => x.Bar, [Rnd.Lng, Rnd.Lng]); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -59,11 +61,12 @@ public void Values_Not_Equal__Throws_EqualTypeException() var fluent = Create(); var values = new[] { Rnd.Str, Rnd.Str }; fluent.WhereNotIn(x => x.Foo, values); + var action = (ICall c) => FluentQueryHelper.AssertWhereNotIn(c, x => x.Foo, [Rnd.Str, Rnd.Str]); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhereNotIn(c, x => x.Foo, [Rnd.Str, Rnd.Str]); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhere_Tests.cs b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhere_Tests.cs index 36afd88cf..0016d4af3 100644 --- a/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhere_Tests.cs +++ b/tests/Tests.Jeebs.Data.Testing/Query/FluentQueryHelper/AssertWhere_Tests.cs @@ -63,14 +63,16 @@ public void Incorrect_Method__Throws_MethodNameException() // Arrange var fluent = Create(); fluent.Maximum(Rnd.ULng); - - // Act var a0 = (ICall c) => FluentQueryHelper.AssertWhere(c, x => x.Foo, Compare.Equal, Rnd.Str); var a1 = (ICall c) => FluentQueryHelper.AssertWhere(c, Rnd.Str, Rnd.Str); + // Act + var r0 = Record.Exception(() => fluent.AssertCalls(a0)); + var r1 = Record.Exception(() => fluent.AssertCalls(a1)); + // Assert - Assert.Throws(() => fluent.AssertCalls(a0)); - Assert.Throws(() => fluent.AssertCalls(a1)); + Assert.IsType(r0); + Assert.IsType(r1); } [Fact] @@ -81,12 +83,13 @@ public void Incorrect_Generic_Argument__Throws_GenericArgumentException() var compare = Compare.Like; var value = Rnd.Str; fluent.Where(x => x.Foo, compare, value); + var action = (ICall c) => FluentQueryHelper.AssertWhere(c, nameof(TestEntity.Foo), compare, Rnd.Lng); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhere(c, nameof(TestEntity.Foo), compare, Rnd.Lng); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -97,12 +100,13 @@ public void No_Generic_Argument__Throws_GenericArgumentException() var compare = Compare.Like; var value = Rnd.Str; fluent.Where(nameof(TestEntity.Foo), compare, value); + var action = (ICall c) => FluentQueryHelper.AssertWhere(c, x => x.Foo, compare, value); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhere(c, x => x.Foo, compare, value); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -113,12 +117,13 @@ public void Compare_Not_Equal__Throws_EqualTypeException() var c0 = Compare.Is; var c1 = Compare.IsNot; fluent.Where(x => x.Foo, c0, Rnd.Str); + var action = (ICall c) => FluentQueryHelper.AssertWhere(c, x => x.Foo, c1, Rnd.Str); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhere(c, x => x.Foo, c1, Rnd.Str); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -130,12 +135,13 @@ public void Value_Not_Equal__Throws_EqualTypeException() var v1 = Rnd.Lng; var compare = Compare.LessThanOrEqual; fluent.Where(x => x.Bar, compare, v0); + var action = (ICall c) => FluentQueryHelper.AssertWhere(c, x => x.Bar, compare, v1); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhere(c, x => x.Bar, compare, v1); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -145,12 +151,13 @@ public void Clause_Not_Equal_Throws_EqualTypeException() var fluent = Create(); var parameters = new { value = Rnd.Guid }; fluent.Where(Rnd.Str, parameters); + var action = (ICall c) => FluentQueryHelper.AssertWhere(c, Rnd.Str, parameters); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhere(c, Rnd.Str, parameters); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } [Fact] @@ -160,11 +167,12 @@ public void Parameters_Not_Equal__Throws_EqualJsonException() var fluent = Create(); var clause = Rnd.Str; fluent.Where(clause, Rnd.Lng); + var action = (ICall c) => FluentQueryHelper.AssertWhere(c, clause, Rnd.Lng); // Act - var action = (ICall c) => FluentQueryHelper.AssertWhere(c, clause, Rnd.Lng); + var result = Record.Exception(() => fluent.AssertCalls(action)); // Assert - Assert.Throws(() => fluent.AssertCalls(action)); + Assert.IsType(result); } } diff --git a/tests/Tests.Jeebs.Data/Map/_/EntityMapper/Map_Tests.cs b/tests/Tests.Jeebs.Data/Map/_/EntityMapper/Map_Tests.cs index 912f58e80..8e5a9ef3c 100644 --- a/tests/Tests.Jeebs.Data/Map/_/EntityMapper/Map_Tests.cs +++ b/tests/Tests.Jeebs.Data/Map/_/EntityMapper/Map_Tests.cs @@ -32,10 +32,10 @@ public void Table_Missing_Column_Throws_InvalidTableMapException() var field = nameof(Foo.Bar0); // Act - var action = void () => mapper.Map(new()); + var result = Record.Exception(() => mapper.Map(new())); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Single(ex.Errors).AssertMessage( "The definition of table '{Table}' is missing field '{Field}'.", table, field @@ -51,10 +51,10 @@ public void Entity_Missing_Property_Throws_InvalidTableMapException() var property = nameof(FooTableWithBar2.Bar2); // Act - var action = void () => mapper.Map(new()); + var result = Record.Exception(() => mapper.Map(new())); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Single(ex.Errors).AssertMessage( "The definition of entity '{Entity}' is missing property '{Property}'.", entity, property @@ -69,10 +69,10 @@ public void Missing_Id_Property_Attribute_Throws_UnableToFindIdColumnException() var name = nameof(FooTableWithoutIdAttribute); // Act - var action = void () => mapper.Map(new()); + var result = Record.Exception(() => mapper.Map(new())); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Single(ex.Errors).AssertMessage("Unable to get Id column from table '{Name}': Cannot get single value from an empty list.", name); } @@ -84,10 +84,10 @@ public void Multiple_Id_Properties_Throws_UnableToFindIdColumnException() var name = nameof(FooTableWithMultipleIdAttributes); // Act - var action = void () => svc.Map(new()); + var result = Record.Exception(() => svc.Map(new())); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Single(ex.Errors).AssertMessage( "Unable to get Id column from table '{Name}': Cannot get single value from a list with multiple values.", name @@ -103,10 +103,10 @@ public void Missing_Version_Property_Attribute_Throws_UnableToFindVersionColumnE var table = nameof(FooTableWithoutVersionAttribute); // Act - var action = void () => mapper.Map(new()); + var result = Record.Exception(() => mapper.Map(new())); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Single(ex.Errors).AssertMessage( "Unable to get single column with attribute '{Attribute}' from table '{Table}': Cannot get single value from an empty list.", attribute, table @@ -122,10 +122,10 @@ public void Multiple_Version_Properties_Throws_UnableToFindVersionColumnExceptio var table = nameof(FooTableWithMultipleVersionAttributes); // Act - var action = void () => svc.Map(new()); + var result = Record.Exception(() => svc.Map(new())); // Assert - var ex = Assert.Throws(action); + var ex = Assert.IsType(result); Assert.Single(ex.Errors).AssertMessage( "Unable to get single column with attribute '{Attribute}' from table '{Table}': Cannot get single value from a list with multiple values.", attribute, table diff --git a/tests/Tests.Jeebs.Data/TypeHandlers/Guid/Parse_Tests.cs b/tests/Tests.Jeebs.Data/TypeHandlers/Guid/Parse_Tests.cs index 7febd3667..d04e5d751 100644 --- a/tests/Tests.Jeebs.Data/TypeHandlers/Guid/Parse_Tests.cs +++ b/tests/Tests.Jeebs.Data/TypeHandlers/Guid/Parse_Tests.cs @@ -31,10 +31,10 @@ public void Invalid_Guid_Throws_FormatException(object input) var handler = new GuidTypeHandler(); // Act - var action = void () => handler.Parse(input); + var result = Record.Exception(() => handler.Parse(input)); // Assert - Assert.Throws(action); + Assert.IsType(result); } [Fact] diff --git a/tests/Tests.Jeebs.Data/TypeHandlers/Json/Parse_Tests.cs b/tests/Tests.Jeebs.Data/TypeHandlers/Json/Parse_Tests.cs index 4545fa593..294119385 100644 --- a/tests/Tests.Jeebs.Data/TypeHandlers/Json/Parse_Tests.cs +++ b/tests/Tests.Jeebs.Data/TypeHandlers/Json/Parse_Tests.cs @@ -17,10 +17,10 @@ public void Null_Or_Whitespace_Throws_JsonException(string input) var handler = new JsonTypeHandler(); // Act - var action = void () => handler.Parse(input); + var result = Record.Exception(() => handler.Parse(input)); // Assert - Assert.Throws(action); + Assert.IsType(result); } [Fact] @@ -31,10 +31,10 @@ public void InvalidJson_Throws_JsonException() var input = Rnd.Str; // Act - var action = void () => handler.Parse(input); + var result = Record.Exception(() => handler.Parse(input)); // Assert - Assert.Throws(action); + Assert.IsType(result); } [Fact] diff --git a/tests/Tests.Jeebs.WordPress/TypeHandlers/Boolean/SetValue_Tests.cs b/tests/Tests.Jeebs.WordPress/TypeHandlers/Boolean/SetValue_Tests.cs index fa039d8a4..c520d1579 100644 --- a/tests/Tests.Jeebs.WordPress/TypeHandlers/Boolean/SetValue_Tests.cs +++ b/tests/Tests.Jeebs.WordPress/TypeHandlers/Boolean/SetValue_Tests.cs @@ -48,9 +48,9 @@ public void Invalid_Column_Throws_InvalidOperationException(bool input) parameter.SourceColumn.Returns(column); // Act - var action = void () => handler.SetValue(parameter, input); + var result = Record.Exception(() => handler.SetValue(parameter, input)); // Assert - Assert.Throws(action); + Assert.IsType(result); } } From 72b6acc07ed73e924b8dbcf16aa0d58f542fa2d6 Mon Sep 17 00:00:00 2001 From: bfren Date: Thu, 29 Jan 2026 15:23:41 +0000 Subject: [PATCH 04/12] Updating packages - #531 --- Directory.Packages.props | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 0308a6631..d8ec0f4f1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -31,7 +31,7 @@ - + @@ -45,10 +45,10 @@ - - - - + + + + From 5e34f56dc9da7ac785eb6a67565431013bb4145b Mon Sep 17 00:00:00 2001 From: bfren Date: Thu, 29 Jan 2026 15:24:12 +0000 Subject: [PATCH 05/12] Removing StringF.Format - moved to Wrap - #531 --- src/Jeebs/Functions/String/StringF.Format.cs | 105 ------------------ src/Jeebs/Functions/StringF.cs | 9 -- .../StringExtensions/FormatWith_Tests.cs | 2 +- .../Functions/_/StringF/Format_Tests.cs | 36 ------ 4 files changed, 1 insertion(+), 151 deletions(-) delete mode 100644 src/Jeebs/Functions/String/StringF.Format.cs delete mode 100644 src/Jeebs/Functions/StringF.cs delete mode 100644 tests/Tests.Jeebs/Functions/_/StringF/Format_Tests.cs diff --git a/src/Jeebs/Functions/String/StringF.Format.cs b/src/Jeebs/Functions/String/StringF.Format.cs deleted file mode 100644 index df886d744..000000000 --- a/src/Jeebs/Functions/String/StringF.Format.cs +++ /dev/null @@ -1,105 +0,0 @@ -// Jeebs Rapid Application Development -// Copyright (c) bfren - licensed under https://mit.bfren.dev/2013 - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text.RegularExpressions; - -namespace Jeebs.Functions; - -public static partial class StringF -{ - /// - /// If is not null, use string.Format() - - /// otherwise, return . - /// - /// Object type. - /// Format string. - /// Object (nullable). - /// String to use when is null. - /// Formatted string. - public static string Format(string formatString, T obj, string? ifNull) => - obj switch - { - T x => - string.Format(F.DefaultCulture, formatString, x), - - _ => - ifNull ?? formatString - }; - - /// - /// Works like string.Format() but with named as well as numbered placeholders. - /// Source is Array: values will be inserted in order (regardless of placeholder values). - /// Source is Object: property names must match placeholders or they will be left in place. - /// - /// - /// Inspired by http://james.newtonking.com/archive/2008/03/29/formatwith-2-0-string-formatting-with-named-variables, - /// (significantly) altered to work without requiring DataBinder. - /// - /// Source type. - /// String to format. - /// Source object to use for template values. - /// Formatted string. - public static string Format(string formatString, T source) - { - // Return original if source is null or if it is an empty array - if (source is null) - { - return formatString; - } - else if (source is Array arr && arr.Length == 0) - { - return formatString; - } - - // Thanks James Newton-King! - var r = TemplateMatcherRegex(); - - var values = new List(); - var replaceIndex = 0; // keeps track of replace loop so we can match named template values with an array source - var rewrittenFormat = r.Replace(formatString, (m) => - { - var startGroup = m.Groups["start"]; - var templateGroup = m.Groups["template"]; - var formatGroup = m.Groups["format"]; - var endGroup = m.Groups["end"]; - - // This is the value inside the braces, e.g. "0" in "{0}" or "A" in "{A}" - // Remove any @ symbols from the start - used by Serilog to denote an object format - // but breaks the following - var template = templateGroup.Value.TrimStart('@'); - - // Switch on the source type, using variety of methods to get this template's value - var flags = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance; - var value = source switch - { - // Source array - get next item in array - Array arr when replaceIndex < arr.Length && arr.GetValue(replaceIndex++) is object val => - val, - - // Source object - get matching property value - { } obj when typeof(T).GetProperty(template, flags)?.GetValue(obj) is object val => - val, - - // Nothing has matched yet so to be safe put the template back - _ => - $"{{{template}}}" - }; - - values.Add(value); - - // Recreate format using zero-based string - return new string('{', startGroup.Captures.Count) - + (values.Count - 1) - + formatGroup.Value - + new string('}', endGroup.Captures.Count); - }); - - return string.Format(F.DefaultCulture, rewrittenFormat, [.. values]); - } - - [GeneratedRegex("(?\\{)+(?