From 232cc4748f8ce4dd59845c55ded4b70e23c95f63 Mon Sep 17 00:00:00 2001 From: "Eric Sibly [chullybun]" Date: Fri, 1 Dec 2023 18:58:53 -0800 Subject: [PATCH] Latest UnitTestEx and CoreEx (#229) --- .github/workflows/CI.yml | 1 + CHANGELOG.md | 7 +++ Common.targets | 2 +- .../Cdr.Banking.Api/Cdr.Banking.Api.csproj | 2 +- .../Cdr.Banking.Business.csproj | 4 +- .../Cdr.Banking.Common.csproj | 2 +- .../Cdr.Banking.Test/AccountTest.cs | 4 +- .../Cdr.Banking.Test/Cdr.Banking.Test.csproj | 4 +- .../Cdr.Banking.Test/TransactionArgsTest.cs | 13 +++--- .../Demo/Beef.Demo.Api/Beef.Demo.Api.csproj | 2 +- .../Beef.Demo.Business.csproj | 14 +++--- .../Beef.Demo.Common/Beef.Demo.Common.csproj | 2 +- .../Demo/Beef.Demo.Test/Beef.Demo.Test.csproj | 5 ++- samples/Demo/Beef.Demo.Test/ContactTest.cs | 44 +++++++++--------- samples/Demo/Beef.Demo.Test/GenderTest.cs | 10 ++--- samples/Demo/Beef.Demo.Test/PersonTest.cs | 15 ++++--- samples/Demo/Beef.Demo.Test/PostalInfoTest.cs | 4 +- samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj | 2 +- .../My.Hr.Business/My.Hr.Business.csproj | 8 ++-- .../My.Hr/My.Hr.Common/My.Hr.Common.csproj | 2 +- samples/My.Hr/My.Hr.Test/Apis/FixtureSetup.cs | 4 +- samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj | 6 +-- .../Validators/EmployeeValidatorTest.cs | 45 +++++++++---------- .../PerformanceReviewValidatorTest.cs | 39 ++++++++-------- .../MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj | 6 +-- samples/MyEf.Hr/MyEf.Hr.Api/Startup.cs | 2 - .../MyEf.Hr.Business/MyEf.Hr.Business.csproj | 8 ++-- .../MyEf.Hr.Common/MyEf.Hr.Common.csproj | 2 +- .../MyEf.Hr.Security.Subscriptions.csproj | 4 +- .../MyEf.Hr.Security.Test/GlobalUsings.cs | 1 + .../MyEf.Hr.Security.Test.csproj | 4 +- .../SecuritySubscriberFunctionTest.cs | 2 +- .../MyEf.Hr/MyEf.Hr.Test/Apis/FixtureSetup.cs | 4 +- .../MyEf.Hr.Test/Apis/ReferenceDataTest.cs | 6 +-- .../MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj | 6 +-- .../Validators/EmployeeValidatorTest.cs | 45 +++++++++---------- .../PerformanceReviewValidatorTest.cs | 36 +++++++-------- .../content/.template.config/template.json | 12 +---- .../Company.AppName.Test/Apis/FixtureSetup.cs | 12 ++--- .../Company.AppName.Test.csproj | 2 +- .../Validators/PersonValidatorTest.cs | 12 ++--- .../Beef.Template.Solution.UnitTest.csproj | 2 +- .../Beef.CodeGen.Core.csproj | 2 +- .../Beef.Database.Core.csproj | 4 +- .../Beef.Database.MySql.csproj | 4 +- .../Beef.Database.SqlServer.csproj | 4 +- tools/Beef.Test.NUnit/AgentTester.cs | 4 +- tools/Beef.Test.NUnit/AgentTesterT.cs | 16 ++++--- tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj | 3 +- tools/Beef.Test.NUnit/ExtensionMethods.cs | 20 +-------- tools/Beef.Test.NUnit/TestSetUpAttribute.cs | 32 ++++--------- .../Beef.Test.NUnit/UsingAgentTesterServer.cs | 4 +- 52 files changed, 231 insertions(+), 269 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 642c97110..8da2c7cc8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -56,6 +56,7 @@ jobs: dotnet-version: | 6.0.x 7.0.x + 8.0.x # Tools diff --git a/CHANGELOG.md b/CHANGELOG.md index c6056f060..e2360fbe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ Represents the **NuGet** versions. +## v5.7.0 +- *Enhancement:* `UnitTestEx` as of `v4.0.0` removed all dependencies to `CoreEx`; the equivalent functionality has been included in new `CoreEx.UnitTest` and `CoreEx.UnitTest.NUnit` (`v3.6.0`) packages. Replace existing `UnitTestEx.NUnit` package with the corresponding `CoreEx.UnitTesting.NUnit` package. + - Unfortunately, this change has resulted in a number of breaking changes that will require manual remediation to existing unit tests; see the `UnitTestEx` [change log](https://github.com/Avanade/UnitTestEx/blob/main/CHANGELOG.md#v400) and `CoreEx` [change log](https://github.com/Avanade/CoreEx/blob/main/CHANGELOG.md#v360) for details and instructions to remediate. + - Upgraded `CoreEx` (`v3.6.0`) to include all related fixes and improvements. + - Upgraded `UnitTestEx` (`v4.0.0`) to include all related fixes and improvements +- *Enhancement:* Added `net7.0` and `net8.0` support. + ## v5.6.9 - *Fixed:* The `yaml` sub-command generated code updated to leverage the new `Entity.Behavior`, being `behavior: cgupd`, where CRUD capabilities are requested. diff --git a/Common.targets b/Common.targets index a0ececa56..575ccd7cf 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@ - 5.6.9 + 5.7.0 preview Avanade Avanade diff --git a/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj b/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj index b9c551ec4..56914d846 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj @@ -5,7 +5,7 @@ true - + diff --git a/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj b/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj index 6920faafb..701a52ed6 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj @@ -11,7 +11,7 @@ - - + + \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj b/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj index bf236788c..db58e9882 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj @@ -8,6 +8,6 @@ - + \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/AccountTest.cs b/samples/Cdr.Banking/Cdr.Banking.Test/AccountTest.cs index 9e3faf8c9..302320bab 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/AccountTest.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Test/AccountTest.cs @@ -27,7 +27,7 @@ public void OneTimeSetUp() [Test] public void B110_GetAccounts_User1() { - var v = Agent() + var v = this.Agent() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetAccountsAsync(null)).Value; @@ -223,7 +223,7 @@ public void C140_GetDetail_NoAuth() [Test] public void D110_GetBalance_Found() { - var v = Agent() + var v = this.Agent() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetBalanceAsync("12345678")).Value; diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj index f794f7770..c814ec6ef 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj @@ -34,8 +34,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/TransactionArgsTest.cs b/samples/Cdr.Banking/Cdr.Banking.Test/TransactionArgsTest.cs index 50719400f..1c7571c4d 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/TransactionArgsTest.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Test/TransactionArgsTest.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using System; using System.Threading.Tasks; +using UnitTestEx; using UnitTestEx.Expectations; using UnitTestEx.NUnit; @@ -16,7 +17,7 @@ public class TransactionArgsTest public async Task A110_ArgsValidator_Empty() { var ta = new TransactionArgs(); - var r = await ValidationTester.Create().RunAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); + var r = await GenericTester.Create().Validation().WithAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); Assert.IsFalse(r!.Result.HasErrors); Assert.AreEqual(DateTime.UtcNow.Date.AddDays(-90), ta.FromDate!.Value.Date); @@ -30,7 +31,7 @@ public async Task A110_ArgsValidator_Empty() public async Task A120_ArgsValidator_ToDateOnly() { var ta = new TransactionArgs { ToDate = new DateTime(2020, 03, 01) }; - var r = await ValidationTester.Create().RunAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); + var r = await GenericTester.Create().Validation().WithAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); Assert.IsFalse(r!.Result.HasErrors); Assert.AreEqual(new DateTime(2020, 03, 01).AddDays(-90), ta.FromDate); @@ -44,7 +45,7 @@ public async Task A120_ArgsValidator_ToDateOnly() public async Task A130_ArgsValidator_ValidSame() { var ta = new TransactionArgs { FromDate = new DateTime(2020, 03, 01), ToDate = new DateTime(2020, 03, 01), MinAmount = 100m, MaxAmount = 100m, Text = "Best Buy" }; - var r = await ValidationTester.Create().RunAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); + var r = await GenericTester.Create().Validation().WithAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); Assert.IsFalse(r!.Result.HasErrors); Assert.AreEqual(new DateTime(2020, 03, 01), ta.FromDate); @@ -58,7 +59,7 @@ public async Task A130_ArgsValidator_ValidSame() public async Task A140_ArgsValidator_ValidDiff() { var ta = new TransactionArgs { FromDate = new DateTime(2020, 03, 01), ToDate = new DateTime(2020, 04, 01), MinAmount = 100m, MaxAmount = 120m, Text = "Best Buy" }; - var r = await ValidationTester.Create().RunAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); + var r = await GenericTester.Create().Validation().WithAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); Assert.IsFalse(r!.Result.HasErrors); Assert.AreEqual(new DateTime(2020, 03, 01), ta.FromDate); @@ -72,13 +73,13 @@ public async Task A140_ArgsValidator_ValidDiff() public async Task A150_ArgsValidator_Invalid() { var ta = new TransactionArgs { FromDate = new DateTime(2020, 03, 01), ToDate = new DateTime(2020, 02, 01), MinAmount = 100m, MaxAmount = 80m, Text = "Best*Buy" }; - await ValidationTester.Create() + await GenericTester.Create() .ConfigureServices(sc => sc.AddValidationTextProvider()) .ExpectErrors( "Oldest time must be less than or equal to Newest time.", "Min Amount must be less than or equal to Max Amount.", "Text contains invalid or non-supported wildcard selection.") - .RunAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); + .Validation().WithAsync(async () => await new TransactionArgsValidator().ValidateAsync(ta)); } } } \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj b/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj index 371111564..7209b00ed 100644 --- a/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj +++ b/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj @@ -12,7 +12,7 @@ - + diff --git a/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj b/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj index dbfa6456b..99cc4aa60 100644 --- a/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj +++ b/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj @@ -15,13 +15,13 @@ - - - - - - - + + + + + + + diff --git a/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj b/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj index 1c63f6157..1330e08d8 100644 --- a/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj +++ b/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj @@ -7,7 +7,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj index f644d19d1..c7c58f4dd 100644 --- a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj +++ b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj @@ -52,12 +52,13 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/samples/Demo/Beef.Demo.Test/ContactTest.cs b/samples/Demo/Beef.Demo.Test/ContactTest.cs index 205aec519..1974a9a31 100644 --- a/samples/Demo/Beef.Demo.Test/ContactTest.cs +++ b/samples/Demo/Beef.Demo.Test/ContactTest.cs @@ -24,7 +24,7 @@ public void A110_Get() { using var test = ApiTester.Create(); - var r = test.Agent() + var r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .ExpectValue((t) => new Contact { Id = 1.ToGuid(), FirstName = "Jenny", LastName = "Cuthbert", Status = "P", StatusDescription = "Pending", Communications = new ContactCommCollection { { "home", new ContactComm { Value = "411671953", IsPreferred = true } }, { "fax", new ContactComm { Value = "411123789" } } } }) .Run(a => a.GetAsync(1.ToGuid())); @@ -32,7 +32,7 @@ public void A110_Get() Assert.NotNull(r.Response.Headers?.ETag?.Tag); var etag = r.Response.Headers?.ETag?.Tag; - r = test.Agent() + r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .ExpectValue((t) => new Contact { Id = 1.ToGuid(), FirstName = "Jenny", LastName = "Cuthbert", Status = "P", StatusDescription = "Pending", Communications = new ContactCommCollection { { "home", new ContactComm { Value = "411671953", IsPreferred = true } }, { "fax", new ContactComm { Value = "411123789" } } } }) .Run(a => a.GetAsync(1.ToGuid())); @@ -46,18 +46,18 @@ public void A112_Patch_Dict() { using var test = ApiTester.Create(); - var v = test.Agent() + var v = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetAsync(1.ToGuid())).Value!; v.Communications.Remove("fax"); v.Communications.Add("mobile", new ContactComm { Value = "4258762983" }); - test.Agent() + test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.PatchAsync(CoreEx.Http.HttpPatchOption.MergePatch, "{\"communications\":{\"mobile\":{\"value\":\"4258762983\"},\"fax\":null}}", 1.ToGuid())); - test.Agent() + test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .ExpectValue(v) .Run(a => a.GetAsync(1.ToGuid())); @@ -68,11 +68,11 @@ public void A112a_Patch_Dict_KeyError() { using var test = ApiTester.Create(); - test.Agent() + test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetAsync(1.ToGuid())); - test.Agent() + test.Agent().With() .ExpectStatusCode(HttpStatusCode.BadRequest) .ExpectErrors("Communication Type is invalid.") .Run(a => a.PatchAsync(CoreEx.Http.HttpPatchOption.MergePatch, "{\"communications\":{\"xyz\":{\"value\":\"4258762983\"},\"fax\":null}}", 1.ToGuid())); @@ -83,11 +83,11 @@ public void A112b_Patch_Dict_ValueError() { using var test = ApiTester.Create(); - test.Agent() + test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetAsync(1.ToGuid())); - test.Agent() + test.Agent().With() .ExpectStatusCode(HttpStatusCode.BadRequest) .ExpectErrors( "Value is required.", @@ -100,7 +100,7 @@ public void A120_Get_LogicallyDeleted() { using var test = ApiTester.Create(); - var r = test.Agent() + var r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.NotFound) .Run(a => a.GetAsync(2.ToGuid())); } @@ -110,7 +110,7 @@ public void A130_Update_LogicallyDeleted() { using var test = ApiTester.Create(); - var r = test.Agent() + var r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.NotFound) .Run(a => a.UpdateAsync(new Contact { Id = 2.ToGuid(), FirstName = "Jenny", LastName = "Cuthbert" }, 2.ToGuid())); } @@ -120,7 +120,7 @@ public void A140_UpdateAndCheckEventOutboxDequeue() { using var test = ApiTester.Create(); - var r = test.Agent() + var r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .ExpectValue((t) => new Contact { Id = 1.ToGuid(), FirstName = "Jenny", LastName = "Cuthbert", Status = "P", StatusDescription = "Pending" }, "Communications") .Run(a => a.GetAsync(1.ToGuid())); @@ -137,7 +137,7 @@ public void A140_UpdateAndCheckEventOutboxDequeue() var v = r.Value; v.LastName += "X"; - r = test.Agent() + r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .ExpectValue((t) => v) .Run(a => a.UpdateAsync(v, 1.ToGuid())); @@ -167,14 +167,14 @@ public void A150_GetAll() { using var test = ApiTester.Create(); - var r = test.Agent() + var r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetAllAsync()); Assert.NotNull(r.Response.Headers?.ETag?.Tag); var etag = r.Response.Headers?.ETag?.Tag; - r = test.Agent() + r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetAllAsync()); @@ -185,12 +185,12 @@ public void A150_GetAll() v.LastName += "X"; // Update and ensure that the etag has changed as a result. - var r2 = test.Agent() + var r2 = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .ExpectValue((t) => v) .Run(a => a.UpdateAsync(v, v.Id)); - r = test.Agent() + r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetAllAsync()); @@ -203,15 +203,15 @@ public void A160_Delete() { using var test = ApiTester.Create(); - test.Agent() + test.Agent().With() .ExpectStatusCode(HttpStatusCode.NoContent) .Run(a => a.DeleteAsync(1.ToGuid())); - var r = test.Agent() + var r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.NotFound) .Run(a => a.GetAsync(1.ToGuid())); - test.Agent() + test.Agent().With() .ExpectStatusCode(HttpStatusCode.NoContent) .Run(a => a.DeleteAsync(1.ToGuid())); @@ -232,7 +232,7 @@ public void A200_RaiseEvent_EventOutboxFailure() { using var test = ApiTester.Create(); - var r = test.Agent() + var r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.InternalServerError) .Run(a => a.RaiseEventAsync(true)); @@ -247,7 +247,7 @@ public void A210_RaiseEvent_EventOutboxSuccess() { using var test = ApiTester.Create(); - var r = test.Agent() + var r = test.Agent().With() .ExpectStatusCode(HttpStatusCode.NoContent) .Run(a => a.RaiseEventAsync(false)); diff --git a/samples/Demo/Beef.Demo.Test/GenderTest.cs b/samples/Demo/Beef.Demo.Test/GenderTest.cs index 5025b78bf..b7a822186 100644 --- a/samples/Demo/Beef.Demo.Test/GenderTest.cs +++ b/samples/Demo/Beef.Demo.Test/GenderTest.cs @@ -1,17 +1,13 @@ using Beef.Demo.Api; using Beef.Demo.Common.Agents; using Beef.Demo.Common.Entities; -using Beef.Test.NUnit; using NUnit.Framework; using NUnit.Framework.Internal; -using System; -using System.Collections.Generic; using System.Linq; using System.Net; -using System.Text; -using System.Threading.Tasks; -using UnitTestEx.NUnit; +using UnitTestEx; using UnitTestEx.Expectations; +using UnitTestEx.NUnit; namespace Beef.Demo.Test { @@ -23,7 +19,7 @@ public class GenderTest : UsingApiTester [OneTimeSetUp] public void OneTimeSetUp() { - ApiTester.UseJsonSerializer(new CoreEx.Text.Json.ReferenceDataContentJsonSerializer()); + ApiTester.UseJsonSerializer(new CoreEx.Text.Json.ReferenceDataContentJsonSerializer().ToUnitTestEx()); ApiTester.UseExpectedEvents(); Assert.IsTrue(ApiTester.SetUp.SetUp()); diff --git a/samples/Demo/Beef.Demo.Test/PersonTest.cs b/samples/Demo/Beef.Demo.Test/PersonTest.cs index d604db6c0..07d008111 100644 --- a/samples/Demo/Beef.Demo.Test/PersonTest.cs +++ b/samples/Demo/Beef.Demo.Test/PersonTest.cs @@ -85,7 +85,7 @@ public void A140_Validation_Invalid2() AgentTester.Test() .ExpectStatusCode(HttpStatusCode.BadRequest) .ExpectErrorType(ErrorType.ValidationError) - .ExpectMessages( + .ExpectErrors( "First Name must not exceed 50 characters in length.", "Last Name must not exceed 50 characters in length.", "Gender is invalid.", @@ -100,7 +100,7 @@ public void A150_Validation_Detail_History_Invalid() AgentTester.Test() .ExpectStatusCode(HttpStatusCode.BadRequest) .ExpectErrorType(ErrorType.ValidationError) - .ExpectMessages( + .ExpectErrors( "End Date must be greater than or equal to Start Date.", "Start Date must be less than or equal to today.") .Run(a => a.UpdateDetailAsync(new PersonDetail() @@ -120,7 +120,7 @@ public void A160_Validation_Detail_History_Duplicate() AgentTester.Test() .ExpectStatusCode(HttpStatusCode.BadRequest) .ExpectErrorType(ErrorType.ValidationError) - .ExpectMessages("History contains duplicates; Name 'Google' specified more than once.") + .ExpectErrors("History contains duplicates; Name 'Google' specified more than once.") .Run(a => a.UpdateDetailAsync(new PersonDetail() { FirstName = "Barry", LastName = "Smith", Birthday = DateTime.Now.AddDays(-5000), Gender = "M", EyeColor = "BROWN", History = new WorkHistoryCollection { new WorkHistory { Name = "Google", StartDate = new DateTime(1990, 12, 31) }, new WorkHistory { Name = "Google", StartDate = new DateTime(1992, 12, 31) } } }, 1.ToGuid())); @@ -132,7 +132,7 @@ public void A170_Validation_Metadata() AgentTester.Test() .ExpectStatusCode(HttpStatusCode.BadRequest) .ExpectErrorType(ErrorType.ValidationError) - .ExpectMessages( + .ExpectErrors( "Gender is invalid.", "Description must not exceed 10 characters in length.") .Run(a => a.CreateAsync(new Person @@ -527,7 +527,7 @@ public void E130_Create_BadRequest() AgentTester.Test() .ExpectStatusCode(HttpStatusCode.BadRequest) .ExpectErrorType(ErrorType.ValidationError) - .ExpectMessages("Gender is invalid.") + .ExpectErrors("Gender is invalid.") .Run(a => a.CreateAsync(p)); } @@ -1216,6 +1216,7 @@ public void I160_GetNoArgs() { AgentTester.Test() .ExpectStatusCode(HttpStatusCode.OK) + .ExpectETag() .ExpectValue(_ => new Person { FirstName = "No", LastName = "Args" }) .Run(a => a.GetNoArgsAsync()); } @@ -1254,7 +1255,7 @@ public void I410_ParamColl_Error() { AgentTester.Test() .ExpectStatusCode(HttpStatusCode.BadRequest) - .ExpectMessages( + .ExpectErrors( "Addresses must not exceed 2 item(s).", "Street is required.") .Run(a => a.ParamCollAsync(new AddressCollection { new Address { Street = "Aaa", City = "Bbb" }, new Address { Street = "Ccc", City = "Ddd" }, new Address { City = "Xxx" } })); @@ -1265,7 +1266,7 @@ public void I410_ParamColl_Duplicate() { AgentTester.Test() .ExpectStatusCode(HttpStatusCode.BadRequest) - .ExpectMessages("Addresses contains duplicates; Street 'Aaa' specified more than once.") + .ExpectErrors("Addresses contains duplicates; Street 'Aaa' specified more than once.") .Run(a => a.ParamCollAsync(new AddressCollection { new Address { Street = "Aaa", City = "Bbb" }, new Address { Street = "Aaa", City = "Ddd" }})); } diff --git a/samples/Demo/Beef.Demo.Test/PostalInfoTest.cs b/samples/Demo/Beef.Demo.Test/PostalInfoTest.cs index 9bb92be41..2620bae59 100644 --- a/samples/Demo/Beef.Demo.Test/PostalInfoTest.cs +++ b/samples/Demo/Beef.Demo.Test/PostalInfoTest.cs @@ -83,7 +83,7 @@ public void B140_GetPostCodes_MockedHttpClient_NotFound() agentTester.Test() .ExpectStatusCode(HttpStatusCode.OK) .Run(a => a.GetPostCodesAsync("US", "WA", "Redmond")) - .AssertFromJsonResource("B140_GetPostCodes_MockedHttpClient_Found_Response.json"); + .AssertJsonFromResource("B140_GetPostCodes_MockedHttpClient_Found_Response.json"); } [Test, TestSetUp] @@ -102,7 +102,7 @@ public void C110_CreatePostCodes_MockedHttpClient() .ExpectStatusCode(HttpStatusCode.Created) .ExpectValue(_ => v) .Run(a => a.CreatePostCodesAsync(v, "US", "WA", "Bananas")) - .AssertFromJsonResource("B140_GetPostCodes_MockedHttpClient_Found_Response.json") + .AssertJsonFromResource("B140_GetPostCodes_MockedHttpClient_Found_Response.json") .AssertETagHeader("\"MyTestETag\""); // Check that the etag flows all the way through. diff --git a/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj b/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj index 13a648074..96998d543 100644 --- a/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj +++ b/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj @@ -5,7 +5,7 @@ true - + diff --git a/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj b/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj index 062861bfb..ade94d162 100644 --- a/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj +++ b/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj @@ -5,10 +5,10 @@ true - - - - + + + + \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj b/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj index a9fe26740..c9ca24586 100644 --- a/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj +++ b/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj @@ -4,6 +4,6 @@ enable - + \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Test/Apis/FixtureSetup.cs b/samples/My.Hr/My.Hr.Test/Apis/FixtureSetup.cs index 38830e266..b72a55a3a 100644 --- a/samples/My.Hr/My.Hr.Test/Apis/FixtureSetup.cs +++ b/samples/My.Hr/My.Hr.Test/Apis/FixtureSetup.cs @@ -6,8 +6,8 @@ public class FixtureSetUp [OneTimeSetUp] public void OneTimeSetUp() { - TestSetUp.Default.ExpectedEventsEnabled = true; - TestSetUp.Default.ExpectNoEvents = true; + TestSetUp.Default.EnableExpectedEvents(); + TestSetUp.Default.ExpectNoEvents(); TestSetUp.Default.RegisterAutoSetUp(async (count, _, ct) => { diff --git a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj index 37d95e4fd..58ea1c684 100644 --- a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj +++ b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj @@ -32,13 +32,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/samples/My.Hr/My.Hr.Test/Validators/EmployeeValidatorTest.cs b/samples/My.Hr/My.Hr.Test/Validators/EmployeeValidatorTest.cs index 4dd5d41d1..fd5e71061 100644 --- a/samples/My.Hr/My.Hr.Test/Validators/EmployeeValidatorTest.cs +++ b/samples/My.Hr/My.Hr.Test/Validators/EmployeeValidatorTest.cs @@ -42,7 +42,7 @@ public void OneTimeSetUp() [Test] public void A110_Validate_Initial() { - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -53,7 +53,7 @@ public void A110_Validate_Initial() "Birthday is required.", "Start Date is required.", "Phone No is required.") - .Run(new Employee()); + .Validation().With(new Employee()); } [Test] @@ -70,7 +70,7 @@ public void A120_Validate_BadData() PhoneNo = "(425) 333 4444" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -80,7 +80,7 @@ public void A120_Validate_BadData() "Gender is invalid.", "Birthday is invalid as the Employee must be at least 18 years of age.", "Start Date must be greater than or equal to January 1, 1999.") - .Run(e); + .Validation().With(e); } [Test] @@ -89,7 +89,7 @@ public void A130_Validate_Address_Empty() var e = CreateValidEmployee(); e.Address = new Address(); - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -97,7 +97,7 @@ public void A130_Validate_Address_Empty() "City is required.", "State is required.", "Post Code is required.") - .Run(e); + .Validation().With(e); } [Test] @@ -112,13 +112,13 @@ public void A140_Validate_Address_Invalid() PostCode = "XXXXXXXXXX" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( "State is invalid.", "Post Code is invalid.") - .Run(e); + .Validation().With(e); } [Test] @@ -133,11 +133,11 @@ public void A150_Validate_Address_OK() PostCode = "98052" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectSuccess() - .Run(e); + .Validation().With(e); } [Test] @@ -146,7 +146,7 @@ public void A160_Validate_Contacts_Empty() var e = CreateValidEmployee(); e.EmergencyContacts = new EmergencyContactCollection { new EmergencyContact() }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -154,7 +154,7 @@ public void A160_Validate_Contacts_Empty() "Last Name is required.", "Phone No is required.", "Relationship is required.") - .Run(e); + .Validation().With(e); } [Test] @@ -172,11 +172,11 @@ public void A170_Validate_Contacts_Invalid() } }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors("Relationship is invalid.") - .Run(e); + .Validation().With(e); } [Test] @@ -196,11 +196,11 @@ public void A180_Validate_Contacts_TooMany() }); } - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors("Emergency Contacts must not exceed 5 item(s).") - .Run(e); + .Validation().With(e); } [Test] @@ -212,13 +212,12 @@ public void A190_Validate_UpdateTerminated() var eds = new Mock(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync(new Employee { Termination = new TerminationDetail { Date = DateTime.UtcNow } }); - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .MockScoped(eds) .ExpectException().Type("Once an Employee has been Terminated the data can no longer be updated.") - .OperationType(CoreEx.OperationType.Update) - .Run(e); + .Validation(OperationType.Update).With(e); } [Test] @@ -227,12 +226,12 @@ public void B110_CanDelete_NotFound() var eds = new Mock(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync((Employee)null!); - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .MockScoped(eds) .ExpectException().Type() - .Run(async () => await EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid())); + .Validation().With(async () => await EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid())); } [Test] @@ -241,11 +240,11 @@ public void B110_CanDelete_Invalid() var eds = new Mock(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync(new Employee { StartDate = DateTime.UtcNow.AddDays(-1) }); - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .MockScoped(eds) .ExpectException().Type("An employee cannot be deleted after they have started their employment.") - .Run(() => EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid()).Result); + .Validation().With(() => EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid()).Result); } } \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Test/Validators/PerformanceReviewValidatorTest.cs b/samples/My.Hr/My.Hr.Test/Validators/PerformanceReviewValidatorTest.cs index 06120c9d1..512f556a4 100644 --- a/samples/My.Hr/My.Hr.Test/Validators/PerformanceReviewValidatorTest.cs +++ b/samples/My.Hr/My.Hr.Test/Validators/PerformanceReviewValidatorTest.cs @@ -1,4 +1,5 @@ -using My.Hr.Business.Entities; +using Azure; +using My.Hr.Business.Entities; namespace My.Hr.Test.Validators; @@ -36,7 +37,7 @@ public void OneTimeSetUp() [Test] public void A110_Validate_Initial() { - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -44,7 +45,7 @@ public void A110_Validate_Initial() "Date is required.", "Outcome is required.", "Reviewer is required.") - .Run(new PerformanceReview()); + .Validation().With(new PerformanceReview()); } [Test] @@ -59,7 +60,7 @@ public void A120_Validate_BadData() Notes = new string('X', 5000) }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -68,7 +69,7 @@ public void A120_Validate_BadData() "Employee is not found; a valid value is required.", "Reviewer must not exceed 256 characters in length.", "Notes must not exceed 4000 characters in length.") - .Run(pr); + .Validation().With(pr); } [Test] @@ -83,11 +84,11 @@ public void A130_Validate_BeforeStarting() Notes = "Thumbs up!" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors("Date must not be prior to the Employee starting.") - .Run(pr); + .Validation().With(pr); } [Test] @@ -102,11 +103,11 @@ public void A140_Validate_AfterTermination() Notes = "Thumbs up!" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors("Date must not be after the Employee has terminated.") - .Run(pr); + .Validation().With(pr); } [Test] @@ -123,12 +124,11 @@ public void A150_Validate_EmployeeNotFound() }; // Need to set the OperationType to Update to exercise logic. - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) - .OperationType(OperationType.Update) .ExpectErrorType(CoreEx.Abstractions.ErrorType.NotFoundError) - .Run(pr); + .Validation(OperationType.Update).With(pr); } [Test] @@ -145,12 +145,11 @@ public void A160_Validate_EmployeeImmutable() }; // Need to set the OperationType to Update to exercise logic. - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) - .OperationType(OperationType.Update) .ExpectErrors("Employee is not allowed to change; please reset value.") - .Run(pr); + .Validation(OperationType.Update).With(pr); } [Test] @@ -166,11 +165,10 @@ public void A170_Validate_CreateOK() }; // Need to set the OperationType to Create to exercise logic. - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) - .OperationType(OperationType.Create) - .Run(pr); + .Validation(OperationType.Create).With(pr); } [Test] @@ -187,10 +185,9 @@ public void A180_Validate_UpdateOK() }; // Need to set the OperationType to Update to exercise logic. - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) - .OperationType(OperationType.Update) - .Run(pr); + .Validation(OperationType.Update).With(pr); } } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj b/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj index a42d4b3cc..98cf0dc54 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj @@ -6,12 +6,12 @@ True - - + + - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Api/Startup.cs b/samples/MyEf.Hr/MyEf.Hr.Api/Startup.cs index c52310796..e4e1654ae 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Api/Startup.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Api/Startup.cs @@ -4,7 +4,6 @@ using CoreEx.Database; using CoreEx.Events; using CoreEx.Hosting; -using OpenTelemetry.Instrumentation.AspNetCore; using OpenTelemetry.Instrumentation.EntityFrameworkCore; using OpenTelemetry.Trace; using Az = Azure.Messaging.ServiceBus; @@ -83,7 +82,6 @@ public void ConfigureServices(IServiceCollection services) // Add Azure monitor open telemetry. services.AddOpenTelemetry().UseAzureMonitor(); - services.Configure(options => options.RecordException = true); services.Configure(options => options.SetDbStatementForText = true); services.ConfigureOpenTelemetryTracerProvider((sp, builder) => builder.AddSource("CoreEx.*", "MyEf.Hr.*", "Microsoft.EntityFrameworkCore.*", "EntityFrameworkCore.*")); diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj b/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj index 27f2c6f00..782d2d1fe 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj @@ -5,10 +5,10 @@ true - - - - + + + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj b/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj index a9fe26740..c9ca24586 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj @@ -4,6 +4,6 @@ enable - + \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj index eb1136633..554d4239b 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj @@ -16,8 +16,8 @@ - - + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Test/GlobalUsings.cs b/samples/MyEf.Hr/MyEf.Hr.Security.Test/GlobalUsings.cs index 0df61f4ca..0b26e8fb8 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Test/GlobalUsings.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Test/GlobalUsings.cs @@ -6,5 +6,6 @@ global using MyEf.Hr.Security.Subscriptions; global using NUnit.Framework.Internal; global using System.Net; +global using UnitTestEx; global using UnitTestEx.Expectations; global using UnitTestEx.NUnit; \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj index be33cfb9e..3c429704b 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj @@ -17,7 +17,7 @@ - + @@ -28,7 +28,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Test/SecuritySubscriberFunctionTest.cs b/samples/MyEf.Hr/MyEf.Hr.Security.Test/SecuritySubscriberFunctionTest.cs index 9cc43a80d..365e1a56f 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Test/SecuritySubscriberFunctionTest.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Test/SecuritySubscriberFunctionTest.cs @@ -8,7 +8,7 @@ public void InvalidMessage_DeadLetter() { using var test = FunctionTester.Create(); var actions = test.CreateServiceBusMessageActions(); - var message = test.CreateServiceBusMessage(null!); + var message = test.CreateServiceBusMessageFromValue(null!); test.ServiceBusTrigger() .Run(f => f.RunAsync(message, actions, default)) diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/Apis/FixtureSetup.cs b/samples/MyEf.Hr/MyEf.Hr.Test/Apis/FixtureSetup.cs index 9c8b20a76..4ec3f26cb 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/Apis/FixtureSetup.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Test/Apis/FixtureSetup.cs @@ -6,8 +6,8 @@ public class FixtureSetUp [OneTimeSetUp] public void OneTimeSetUp() { - TestSetUp.Default.ExpectedEventsEnabled = true; - TestSetUp.Default.ExpectNoEvents = true; + TestSetUp.Default.EnableExpectedEvents(); + TestSetUp.Default.ExpectNoEvents(); TestSetUp.Default.RegisterAutoSetUp(async (count, _, ct) => { diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/Apis/ReferenceDataTest.cs b/samples/MyEf.Hr/MyEf.Hr.Test/Apis/ReferenceDataTest.cs index 3e7081f32..edd33511b 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/Apis/ReferenceDataTest.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Test/Apis/ReferenceDataTest.cs @@ -6,11 +6,7 @@ namespace MyEf.Hr.Test.Apis; public class ReferenceDataTest : UsingApiTester { [OneTimeSetUp] - public void OneTimeSetUp() - { - TestSetUp.Default.SetUp(); - ApiTester.UseJsonSerializer(new CoreEx.Text.Json.ReferenceDataContentJsonSerializer()); - } + public void OneTimeSetUp() => TestSetUp.Default.SetUp(); [Test] public void A110_GendersAll() diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj index ce5a13e61..5cbab020e 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj @@ -32,13 +32,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/Validators/EmployeeValidatorTest.cs b/samples/MyEf.Hr/MyEf.Hr.Test/Validators/EmployeeValidatorTest.cs index 79a5347b1..c21923dc8 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/Validators/EmployeeValidatorTest.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Test/Validators/EmployeeValidatorTest.cs @@ -42,7 +42,7 @@ public void OneTimeSetUp() [Test] public void A110_Validate_Initial() { - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -53,7 +53,7 @@ public void A110_Validate_Initial() "Birthday is required.", "Start Date is required.", "Phone No is required.") - .Run(new Employee()); + .Validation().With(new Employee()); } [Test] @@ -70,7 +70,7 @@ public void A120_Validate_BadData() PhoneNo = "(425) 333 4444" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -80,7 +80,7 @@ public void A120_Validate_BadData() "Gender is invalid.", "Birthday is invalid as the Employee must be at least 18 years of age.", "Start Date must be greater than or equal to January 1, 1999.") - .Run(e); + .Validation().With(e); } [Test] @@ -89,7 +89,7 @@ public void A130_Validate_Address_Empty() var e = CreateValidEmployee(); e.Address = new Address(); - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -97,7 +97,7 @@ public void A130_Validate_Address_Empty() "City is required.", "State is required.", "Post Code is required.") - .Run(e); + .Validation().With(e); } [Test] @@ -112,13 +112,13 @@ public void A140_Validate_Address_Invalid() PostCode = "XXXXXXXXXX" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( "State is invalid.", "Post Code is invalid.") - .Run(e); + .Validation().With(e); } [Test] @@ -133,11 +133,11 @@ public void A150_Validate_Address_OK() PostCode = "98052" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectSuccess() - .Run(e); + .Validation().With(e); } [Test] @@ -146,7 +146,7 @@ public void A160_Validate_Contacts_Empty() var e = CreateValidEmployee(); e.EmergencyContacts = new EmergencyContactCollection { new EmergencyContact() }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -154,7 +154,7 @@ public void A160_Validate_Contacts_Empty() "Last Name is required.", "Phone No is required.", "Relationship is required.") - .Run(e); + .Validation().With(e); } [Test] @@ -172,11 +172,11 @@ public void A170_Validate_Contacts_Invalid() } }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors("Relationship is invalid.") - .Run(e); + .Validation().With(e); } [Test] @@ -196,11 +196,11 @@ public void A180_Validate_Contacts_TooMany() }); } - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors("Emergency Contacts must not exceed 5 item(s).") - .Run(e); + .Validation().With(e); } [Test] @@ -212,13 +212,12 @@ public void A190_Validate_UpdateTerminated() var eds = new Mock(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync(new Employee { Termination = new TerminationDetail { Date = DateTime.UtcNow } }); - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .MockScoped(eds) .ExpectException().Type("Once an Employee has been Terminated the data can no longer be updated.") - .OperationType(OperationType.Update) - .Run(e); + .Validation(OperationType.Update).With(e); } [Test] @@ -227,12 +226,12 @@ public void B110_CanDelete_NotFound() var eds = new Mock(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync((Employee?)null!); - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .MockScoped(eds) .ExpectException().Type() - .Run(async () => await EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid())); + .Validation().With(async () => await EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid())); } [Test] @@ -241,11 +240,11 @@ public void B110_CanDelete_Invalid() var eds = new Mock(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync(new Employee { StartDate = DateTime.UtcNow.AddDays(-1) }); - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .MockScoped(eds) .ExpectException().Type("An employee cannot be deleted after they have started their employment.") - .Run(() => EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid()).Result); + .Validation().With(() => EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid()).Result); } } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/Validators/PerformanceReviewValidatorTest.cs b/samples/MyEf.Hr/MyEf.Hr.Test/Validators/PerformanceReviewValidatorTest.cs index 4cfb1e1e7..a8ae5eea1 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/Validators/PerformanceReviewValidatorTest.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Test/Validators/PerformanceReviewValidatorTest.cs @@ -36,7 +36,7 @@ public void OneTimeSetUp() [Test] public void A110_Validate_Initial() { - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -44,7 +44,7 @@ public void A110_Validate_Initial() "Date is required.", "Outcome is required.", "Reviewer is required.") - .Run(new PerformanceReview()); + .Validation().With(new PerformanceReview()); } [Test] @@ -59,7 +59,7 @@ public void A120_Validate_BadData() Notes = new string('X', 5000) }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors( @@ -68,7 +68,7 @@ public void A120_Validate_BadData() "Employee is not found; a valid value is required.", "Reviewer must not exceed 256 characters in length.", "Notes must not exceed 4000 characters in length.") - .Run(pr); + .Validation().With(pr); } [Test] @@ -83,11 +83,11 @@ public void A130_Validate_BeforeStarting() Notes = "Thumbs up!" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors("Date must not be prior to the Employee starting.") - .Run(pr); + .Validation().With(pr); } [Test] @@ -102,11 +102,11 @@ public void A140_Validate_AfterTermination() Notes = "Thumbs up!" }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) .ExpectErrors("Date must not be after the Employee has terminated.") - .Run(pr); + .Validation().With(pr); } [Test] @@ -123,12 +123,11 @@ public void A150_Validate_EmployeeNotFound() }; // Need to set the OperationType to Update to exercise logic. - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) - .OperationType(OperationType.Update) .ExpectErrorType(CoreEx.Abstractions.ErrorType.NotFoundError) - .Run(pr); + .Validation(OperationType.Update).With(pr); } [Test] @@ -145,12 +144,11 @@ public void A160_Validate_EmployeeImmutable() }; // Need to set the OperationType to Update to exercise logic. - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) - .OperationType(OperationType.Update) .ExpectErrors("Employee is not allowed to change; please reset value.") - .Run(pr); + .Validation(OperationType.Update).With(pr); } [Test] @@ -166,11 +164,10 @@ public void A170_Validate_CreateOK() }; // Need to set the OperationType to Create to exercise logic. - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) - .OperationType(OperationType.Create) - .Run(pr); + .Validation(OperationType.Create).With(pr); } [Test] @@ -187,10 +184,9 @@ public void A180_Validate_UpdateOK() }; // Need to set the OperationType to Update to exercise logic. - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); test.ConfigureServices(_testSetup!) - .OperationType(OperationType.Update) - .Run(pr); + .Validation(OperationType.Update).With(pr); } } \ No newline at end of file diff --git a/templates/Beef.Template.Solution/content/.template.config/template.json b/templates/Beef.Template.Solution/content/.template.config/template.json index 340aff2a7..1e7b000dd 100644 --- a/templates/Beef.Template.Solution/content/.template.config/template.json +++ b/templates/Beef.Template.Solution/content/.template.config/template.json @@ -65,23 +65,15 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "3.4.1" + "value": "3.6.0" }, "replaces": "CoreExVersion" }, - "unittestex_version": { - "type": "generated", - "generator": "constant", - "parameters": { - "value": "3.1.0" - }, - "replaces": "UnitTestExVersion" - }, "beef_version": { "type": "generated", "generator": "constant", "parameters": { - "value": "5.6.9" + "value": "5.7.0" }, "replaces": "BeefVersion" }, diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs b/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs index a669f6137..6d4309ea7 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs +++ b/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs @@ -7,8 +7,8 @@ public class FixtureSetUp [OneTimeSetUp] public void OneTimeSetUp() { - TestSetUp.Default.ExpectedEventsEnabled = true; - TestSetUp.Default.ExpectNoEvents = true; + TestSetUp.Default.EnableExpectedEvents(); + TestSetUp.Default.ExpectNoEvents(); TestSetUp.Default.RegisterAutoSetUp(async (count, _, ct) => { @@ -28,8 +28,8 @@ public void OneTimeSetUp() [OneTimeSetUp] public void OneTimeSetUp() { - TestSetUp.Default.ExpectedEventsEnabled = true; - TestSetUp.Default.ExpectNoEvents = true; + TestSetUp.Default.EnableExpectedEvents(); + TestSetUp.Default.ExpectNoEvents(); TestSetUp.Default.RegisterSetUp(async (count, _, ct) => { @@ -69,8 +69,8 @@ public void OneTimeSetUp() [OneTimeSetUp] public void OneTimeSetUp() { - TestSetUp.Default.ExpectedEventsEnabled = true; - TestSetUp.Default.ExpectNoEvents = true; + TestSetUp.Default.EnableExpectedEvents(); + TestSetUp.Default.ExpectNoEvents(); } #endif } \ No newline at end of file diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Test/Company.AppName.Test.csproj b/templates/Beef.Template.Solution/content/Company.AppName.Test/Company.AppName.Test.csproj index c4a8bdc8d..db6ae0b63 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Test/Company.AppName.Test.csproj +++ b/templates/Beef.Template.Solution/content/Company.AppName.Test/Company.AppName.Test.csproj @@ -29,7 +29,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Test/Validators/PersonValidatorTest.cs b/templates/Beef.Template.Solution/content/Company.AppName.Test/Validators/PersonValidatorTest.cs index 0e8a9a520..fbf88f4f7 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Test/Validators/PersonValidatorTest.cs +++ b/templates/Beef.Template.Solution/content/Company.AppName.Test/Validators/PersonValidatorTest.cs @@ -31,7 +31,7 @@ public void OneTimeSetUp() [Test] public async Task A110_Validation_Empty() { - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); await test .ConfigureServices(_testSetup!) @@ -40,7 +40,7 @@ await test "Last Name is required.", "Gender is required.", "Birthday is required.") - .RunAsync(new Person()); + .Validation().WithAsync(new Person()); } [Test] @@ -54,7 +54,7 @@ public async Task A120_Validation_Invalid() Birthday = DateTime.UtcNow.AddDays(1) }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); await test .ConfigureServices(_testSetup!) @@ -63,7 +63,7 @@ await test "Last Name must not exceed 100 characters in length.", "Gender is invalid.", "Birthday must be less than or equal to Today.") - .RunAsync(p); + .Validation().WithAsync(p); } [Test] @@ -77,11 +77,11 @@ public async Task A130_Validation_OK() Birthday = DateTime.UtcNow.AddYears(-18) }; - using var test = ValidationTester.Create(); + using var test = GenericTester.Create(); await test .ConfigureServices(_testSetup!) .ExpectSuccess() - .RunAsync(p); + .Validation().WithAsync(p); } } \ No newline at end of file diff --git a/tests/Beef.Template.Solution.UnitTest/Beef.Template.Solution.UnitTest.csproj b/tests/Beef.Template.Solution.UnitTest/Beef.Template.Solution.UnitTest.csproj index 1c72ee399..c237be6ba 100644 --- a/tests/Beef.Template.Solution.UnitTest/Beef.Template.Solution.UnitTest.csproj +++ b/tests/Beef.Template.Solution.UnitTest/Beef.Template.Solution.UnitTest.csproj @@ -11,7 +11,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj b/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj index d48af3886..0980ca2a1 100644 --- a/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj +++ b/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net6.0;net7.0;net8.0 Beef.CodeGen Beef.CodeGen.Core Business Entity Execution Framework (Beef) Code Generator tool. diff --git a/tools/Beef.Database.Core/Beef.Database.Core.csproj b/tools/Beef.Database.Core/Beef.Database.Core.csproj index 443440add..b03f14475 100644 --- a/tools/Beef.Database.Core/Beef.Database.Core.csproj +++ b/tools/Beef.Database.Core/Beef.Database.Core.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net7.0;net8.0 Beef.Database.Core Business Entity Execution Framework (Beef) Database tool. beef database dbup migration schema dbex @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.MySql/Beef.Database.MySql.csproj b/tools/Beef.Database.MySql/Beef.Database.MySql.csproj index 6813c90aa..bc63523a9 100644 --- a/tools/Beef.Database.MySql/Beef.Database.MySql.csproj +++ b/tools/Beef.Database.MySql/Beef.Database.MySql.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net7.0;net8.0 Beef.Database.MySql Business Entity Execution Framework (Beef) MySQL Database tool. beef database sql mysql dbup migration schema dbex @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj b/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj index 7295d2efc..377682237 100644 --- a/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj +++ b/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net7.0;net8.0 Beef.Database.SqlServer Business Entity Execution Framework (Beef) SQL Server Database tool. beef database sql sqlserver dbup migration schema dbex @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Test.NUnit/AgentTester.cs b/tools/Beef.Test.NUnit/AgentTester.cs index 48a3b0cca..3cea49305 100644 --- a/tools/Beef.Test.NUnit/AgentTester.cs +++ b/tools/Beef.Test.NUnit/AgentTester.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; +// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef + +using Microsoft.Extensions.DependencyInjection; using System; using UnitTestEx.NUnit; using UnitTestEx.NUnit.Internal; diff --git a/tools/Beef.Test.NUnit/AgentTesterT.cs b/tools/Beef.Test.NUnit/AgentTesterT.cs index 2c9b2652e..0bfe4ef8c 100644 --- a/tools/Beef.Test.NUnit/AgentTesterT.cs +++ b/tools/Beef.Test.NUnit/AgentTesterT.cs @@ -1,6 +1,10 @@ -using Microsoft.AspNetCore.TestHost; +// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef + +using CoreEx; +using Microsoft.AspNetCore.TestHost; using System; using System.Net.Http; +using UnitTestEx; using UnitTestEx.NUnit.Internal; namespace Beef.Test.NUnit @@ -34,7 +38,8 @@ public sealed class AgentTester : IDisposable where TEntryPoint : c /// The . public UnitTestEx.AspNetCore.AgentTester Test(string? userName = null) where TAgent : CoreEx.Http.TypedHttpClientBase { - var at = _parent.Agent(); + var at = _parent.Agent().With(); + userName ??= (ExecutionContext.HasCurrent ? ExecutionContext.Current.UserName : null); if (userName != null) at.WithUser(userName); @@ -49,7 +54,7 @@ public UnitTestEx.AspNetCore.AgentTester Test(string? userName = /// The . public UnitTestEx.AspNetCore.AgentTester Test(object? userIdentifier) where TAgent : CoreEx.Http.TypedHttpClientBase { - var at = _parent.Agent(); + var at = _parent.Agent().With(); if (userIdentifier != null) at.WithUser(userIdentifier); @@ -65,7 +70,8 @@ public UnitTestEx.AspNetCore.AgentTester Test(object? userIdenti /// The . public UnitTestEx.AspNetCore.AgentTester Test(string? userName = null) where TAgent : CoreEx.Http.TypedHttpClientBase { - var at = _parent.Agent(); + var at = _parent.Agent().With(); + userName ??= (ExecutionContext.HasCurrent ? ExecutionContext.Current.UserName : null); if (userName != null) at.WithUser(userName); @@ -81,7 +87,7 @@ public UnitTestEx.AspNetCore.AgentTester TestThe . public UnitTestEx.AspNetCore.AgentTester Test(object? userIdentifier) where TAgent : CoreEx.Http.TypedHttpClientBase { - var at = _parent.Agent(); + var at = _parent.Agent().With(); if (userIdentifier != null) at.WithUser(userIdentifier); diff --git a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj index 307d0b3bf..3f352fcdd 100644 --- a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj +++ b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tools/Beef.Test.NUnit/ExtensionMethods.cs b/tools/Beef.Test.NUnit/ExtensionMethods.cs index 3ce85060e..723b420f9 100644 --- a/tools/Beef.Test.NUnit/ExtensionMethods.cs +++ b/tools/Beef.Test.NUnit/ExtensionMethods.cs @@ -1,5 +1,5 @@ -using CoreEx; -using CoreEx.Entities; +// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef + using CoreEx.Http; using CoreEx.Json; using Moq; @@ -9,8 +9,6 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; -using UnitTestEx; -using UnitTestEx.Expectations; namespace Beef.Test.NUnit { @@ -19,20 +17,6 @@ namespace Beef.Test.NUnit /// public static class ExtensionMethods { - /// - /// Expect a was thrown during execution with the specified messages. - /// - /// The tester . - /// The . - /// The expected message texts. - /// The instance to support fluent-style method-chaining. - /// Provided to support backwards compatibility to earlier Beef versions. It is recommended that usage is upgraded to use as this will eventually be deprecated. - public static TSelf ExpectMessages(this IExceptionSuccessExpectations tester, params string[] messages) where TSelf : IExceptionSuccessExpectations - { - tester.ExceptionSuccessExpectations.SetExpectErrors(messages); - return (TSelf)tester; - } - /// /// Extends to simplify the return of a mocked with the specified (defaults to ). /// diff --git a/tools/Beef.Test.NUnit/TestSetUpAttribute.cs b/tools/Beef.Test.NUnit/TestSetUpAttribute.cs index 72c5d200a..851569274 100644 --- a/tools/Beef.Test.NUnit/TestSetUpAttribute.cs +++ b/tools/Beef.Test.NUnit/TestSetUpAttribute.cs @@ -18,26 +18,18 @@ namespace Beef.Test.NUnit /// Provided to support backwards compatibility to earlier Beef versions. It is recommended that usage is upgraded to the new as this will eventually be deprecated. /// As the attribute is executed by the NUnit runtime outside of the context of the method itself only the is able to be referenced. This, and the challenge of achieving consistency between /// MSTest, NUnit and Xunit is why this feature is being deprecated. + /// The username (null indicates to use the ). [DebuggerStepThrough] [AttributeUsage(AttributeTargets.Method)] - public class TestSetUpAttribute : PropertyAttribute, IWrapSetUpTearDown, ICommandWrapper + public class TestSetUpAttribute(string? username = null) : PropertyAttribute, IWrapSetUpTearDown, ICommandWrapper { private static readonly AsyncLocal _username = new(); - private readonly string _testUsername; + private readonly string _testUsername = username ?? TestSetUp.Default.DefaultUserName; /// /// Gets the username. /// - internal static string Username => _username.Value ?? TestSetUp.Default.DefaultUserName; - - /// - /// Initializes a new instance of the class for a . - /// - /// The username (null indicates to use the ). - public TestSetUpAttribute(string? username = null) - { - _testUsername = username ?? TestSetUp.Default.DefaultUserName; - } + internal static string Username => _username.Value ?? TestSetUp.Default.DefaultUserName; /// /// Initializes a new instance of the class for a . @@ -59,20 +51,12 @@ public TestSetUpAttribute(object? userIdentifier) /// /// The test command for the . /// + /// The inner . + /// The username (null indicates to use the ). [DebuggerStepThrough()] - internal class ExecutionContextCommand : DelegatingTestCommand + internal class ExecutionContextCommand(TestCommand innerCommand, string? username) : DelegatingTestCommand(innerCommand) { - private readonly string _testUsername; - - /// - /// Initializes a new instance of the class. - /// - /// The inner . - /// The username (null indicates to use the ). - public ExecutionContextCommand(TestCommand innerCommand, string? username) : base(innerCommand) - { - _testUsername = username ?? TestSetUp.Default.DefaultUserName; - } + private readonly string _testUsername = username ?? TestSetUp.Default.DefaultUserName; /// /// Executes the test, saving a in the supplied . diff --git a/tools/Beef.Test.NUnit/UsingAgentTesterServer.cs b/tools/Beef.Test.NUnit/UsingAgentTesterServer.cs index 9f8d98c24..5fb694610 100644 --- a/tools/Beef.Test.NUnit/UsingAgentTesterServer.cs +++ b/tools/Beef.Test.NUnit/UsingAgentTesterServer.cs @@ -1,4 +1,6 @@ -using CoreEx; +// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef + +using CoreEx; using System; using UnitTestEx.NUnit;