diff --git a/Dockerfile b/Dockerfile index e761cb3..06bd943 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -# Set the base image as the .NET 6.0 SDK (this includes the runtime) -FROM mcr.microsoft.com/dotnet/sdk:7.0 as build-env +# Set the base image as the .NET 8.0 SDK (this includes the runtime) +FROM mcr.microsoft.com/dotnet/sdk:8.0 as build-env # Copy everything and publish the release (publish implicitly restores and builds) COPY . ./ @@ -14,6 +14,6 @@ LABEL homepage="https://github.com/KinsonDigital/VersionMiner" LABEL com.github.actions.name="Version Miner" # Relayer the .NET SDK, anew with the build output -FROM mcr.microsoft.com/dotnet/sdk:7.0 +FROM mcr.microsoft.com/dotnet/sdk:8.0 COPY --from=build-env /out . ENTRYPOINT [ "dotnet", "/VersionMiner.dll" ] diff --git a/Testing/VersionMinerIntegrationTests/ExtensionMethods.cs b/Testing/VersionMinerIntegrationTests/ExtensionMethods.cs index 1c6152c..a24092e 100644 --- a/Testing/VersionMinerIntegrationTests/ExtensionMethods.cs +++ b/Testing/VersionMinerIntegrationTests/ExtensionMethods.cs @@ -3,10 +3,11 @@ // using FluentAssertions; -using Xunit.Sdk; namespace VersionMinerIntegrationTests; +using FluentAssertions.Execution; + /// /// Provides extension methods for the unit test project. /// @@ -37,31 +38,31 @@ public static void SetPropertyValue(this TObj? obj, string? pr { if (obj is null) { - throw new AssertActualExpectedException( - expected: "Not Null", - actual: "Is Null", - $"The '{nameof(obj)}' parameter must not be null for this assertion to be completed."); + var exMsg = "Expected: Not Null"; + exMsg += "\nActual: Is Null"; + exMsg += $"\nThe '{nameof(obj)}' parameter must not be null for this assertion to be completed."; + throw new AssertionFailedException(exMsg); } if (string.IsNullOrEmpty(propName)) { - throw new AssertActualExpectedException( - expected: propName is null ? "Not Null" : "Not Empty", - actual: propName is null ? "Is Null" : "Is Empty", - $"The '{nameof(propName)}' parameter must not be null or empty for this assertion to be completed."); + var exMsg = $"Expected: {(propName is null ? "Not Null" : "Not Empty")}"; + exMsg += $"Actual: {(propName is null ? "Is Null" : "Is Empty")}"; + exMsg += $"pnThe '{nameof(propName)}' parameter must not be null or empty for this assertion to be completed."; + + throw new AssertionFailedException(exMsg); } var foundProp = obj.GetType().Properties().FirstOrDefault(p => p.Name == propName && p.PropertyType == propValue.GetType()); if (foundProp is null) { - var msg = $"The property '{propName}' on object '{obj.GetType().Name}' was not found or the property"; - msg += " type does not match the parameter '{{nameof(propValue)}}' type."; + var exMsg = "Expected: Property to be found"; + exMsg += "\nActual: Property was not found"; + exMsg += $"\nThe property '{propName}' on object '{obj.GetType().Name}' was not found or the property"; + exMsg += " type does not match the parameter '{{nameof(propValue)}}' type."; - throw new AssertActualExpectedException( - expected: "Property to be found", - actual: "Property was not found", - msg); + throw new AssertionFailedException(exMsg); } foundProp.SetValue(obj, propValue); diff --git a/Testing/VersionMinerIntegrationTests/VersionMinerIntegrationTests.csproj b/Testing/VersionMinerIntegrationTests/VersionMinerIntegrationTests.csproj index 60bb75a..291093c 100644 --- a/Testing/VersionMinerIntegrationTests/VersionMinerIntegrationTests.csproj +++ b/Testing/VersionMinerIntegrationTests/VersionMinerIntegrationTests.csproj @@ -1,10 +1,10 @@ - net7.0 + net8.0 enable enable - 11.0 + 12.0 false diff --git a/Testing/VersionMinerTests/Helpers/ExtensionMethodsForTesting.cs b/Testing/VersionMinerTests/Helpers/ExtensionMethodsForTesting.cs index 3d03baf..24b73d0 100644 --- a/Testing/VersionMinerTests/Helpers/ExtensionMethodsForTesting.cs +++ b/Testing/VersionMinerTests/Helpers/ExtensionMethodsForTesting.cs @@ -4,10 +4,11 @@ using System.Reflection; using CommandLine; -using Xunit.Sdk; namespace VersionMinerTests.Helpers; +using FluentAssertions.Execution; + /// /// Provides extension/helper methods to assist in unit testing. /// @@ -21,7 +22,7 @@ public static class ExtensionMethodsForTesting /// The name of the property on the object. /// The type of attribute on the property. /// The attribute if it exists. - /// + /// /// Thrown if the property or attribute does not exist. /// public static T GetAttrFromProp(this object value, string propName) @@ -31,13 +32,13 @@ public static T GetAttrFromProp(this object value, string propName) var noPropsAssertMsg = string.IsNullOrEmpty(propName) ? $"Cannot get an attribute on a property when the '{nameof(propName)}' parameter is null or empty." : $"Cannot get an attribute on a property when no property with the name '{propName}' exists."; + var noPropsExMsg = "Expected: at least 1 item"; + noPropsExMsg += "\nActual: 0 items"; + noPropsExMsg += $"\n{noPropsAssertMsg}"; if (props.Length <= 0) { - throw new AssertActualExpectedException( - "at least 1 item.", - "was 0 items.", - noPropsAssertMsg); + throw new AssertionFailedException(noPropsExMsg); } var propNotFoundAssertMsg = $"Cannot get an attribute on the property '{propName}' if the property does not exist."; @@ -47,10 +48,11 @@ public static T GetAttrFromProp(this object value, string propName) if (foundProp is null) { - throw new AssertActualExpectedException( - "not to be null.", - "was null", - propNotFoundAssertMsg); + var notFoundPropExMsg = "Expected: not to be null"; + notFoundPropExMsg += "\nActual: was null"; + notFoundPropExMsg += $"\n{propNotFoundAssertMsg}"; + + throw new AssertionFailedException(notFoundPropExMsg); } var noAttrsAssertMsg = $"Cannot get an attribute when the property '{propName}' does not have any attributes."; @@ -58,10 +60,11 @@ public static T GetAttrFromProp(this object value, string propName) if (attrs.Length <= 0) { - throw new AssertActualExpectedException( - "at least 1 item.", - "was 0 items.", - noAttrsAssertMsg); + var noAttrsExMsg = "Expected: at least 1 item"; + noAttrsExMsg += "\nActual: 0 items"; + noAttrsExMsg += $"\n{noAttrsAssertMsg}"; + + throw new AssertionFailedException(noAttrsExMsg); } return attrs[0]; @@ -81,7 +84,7 @@ public static T GetAttrFromProp(this object value, string propName) /// The expected value of the property. /// The expected value of the property. /// The expected value of the property. - /// + /// /// Thrown if the any of the properties are not the correct values. /// public static void AssertOptionAttrProps(this OptionAttribute value, @@ -92,33 +95,33 @@ public static void AssertOptionAttrProps(this OptionAttribute value, { if (value.LongName != longNameExpected) { - throw new AssertActualExpectedException( - longNameExpected, - value.LongName, + throw new AssertionFailedException( + $"Expected: {longNameExpected}" + + "\nActual: value.LongName" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.LongName)}' property value is not correct for option '{longNameExpected}'."); } if (value.Required != requiredExpected) { - throw new AssertActualExpectedException( - requiredExpected, - value.Required, + throw new AssertionFailedException( + $"{requiredExpected}" + + $"\n{value.Required}" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.Required)}' property value is not correct for option '{longNameExpected}'."); } if (value.Default.ToString() != defaultExpected.ToString()) { - throw new AssertActualExpectedException( - defaultExpected, - value.Default, + throw new AssertionFailedException( + $"{defaultExpected}" + + $"\n{value.Default}" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.Default)}' property value is not correct for option '{defaultExpected}'."); } if (value.HelpText != helpTextExpected) { - throw new AssertActualExpectedException( - helpTextExpected, - value.HelpText, + throw new AssertionFailedException( + $"{helpTextExpected}" + + $"\n{value.HelpText}" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.HelpText)}' property value is not correct for option '{longNameExpected}'."); } } @@ -135,7 +138,7 @@ public static void AssertOptionAttrProps(this OptionAttribute value, /// The expected value of the property. /// The expected value of the property. /// The expected value of the property. - /// + /// /// Thrown if any of the properties are not the correct values. /// public static void AssertOptionAttrProps(this OptionAttribute value, @@ -145,25 +148,25 @@ public static void AssertOptionAttrProps(this OptionAttribute value, { if (value.LongName != longNameExpected) { - throw new AssertActualExpectedException( - longNameExpected, - value.LongName, + throw new AssertionFailedException( + $"{longNameExpected}" + + $"\n{value.LongName}" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.LongName)}' property value is not correct for option '{longNameExpected}'."); } if (value.Required != requiredExpected) { - throw new AssertActualExpectedException( - requiredExpected, - value.Required, + throw new AssertionFailedException( + $"{requiredExpected}" + + $"\n{value.Required}" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.Required)}' property value is not correct for option '{longNameExpected}'."); } if (value.HelpText != helpTextExpected) { - throw new AssertActualExpectedException( - helpTextExpected, - value.HelpText, + throw new AssertionFailedException( + $"{helpTextExpected}" + + $"\n{value.HelpText}" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.HelpText)}' property value is not correct for option '{longNameExpected}'."); } } @@ -179,7 +182,7 @@ public static void AssertOptionAttrProps(this OptionAttribute value, /// The attribute to assert. /// The expected value of the property. /// The expected value of the property. - /// + /// /// Thrown if the any of the properties are not the correct values. /// public static void AssertOptionAttrProps(this OptionAttribute value, @@ -188,17 +191,17 @@ public static void AssertOptionAttrProps(this OptionAttribute value, { if (value.LongName != longNameExpected) { - throw new AssertActualExpectedException( - longNameExpected, - value.LongName, + throw new AssertionFailedException( + $"{longNameExpected}" + + $"\n{value.LongName}" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.LongName)}' property value is not correct."); } if (value.HelpText != helpTextExpected) { - throw new AssertActualExpectedException( - helpTextExpected, - value.HelpText, + throw new AssertionFailedException( + $"{helpTextExpected}" + + $"\n{value.HelpText}" + $"The '{nameof(OptionAttribute)}.{nameof(OptionAttribute.HelpText)}' property value is not correct."); } } @@ -212,7 +215,7 @@ public static void AssertOptionAttrProps(this OptionAttribute value, /// The value of the property. /// The type of object. /// The type of property value. - /// + /// /// Occurs if the parameters or are null. /// Occurs if the property was not found. /// @@ -220,17 +223,17 @@ public static void SetPropValue(this TObj obj, string propName { if (obj is null) { - throw new AssertActualExpectedException( - "Not to be null.", - "Is null.", + throw new AssertionFailedException( + "Expected: Not to be null." + + "\nActual: Is null." + $"The parameter '{nameof(propName)}' must not be null to set the property value"); } if (string.IsNullOrEmpty(propName)) { - throw new AssertActualExpectedException( - "Not to be null or empty.", - "Is null or empty.", + throw new AssertionFailedException( + "Expected: Not to be null or empty." + + "\nActual: Is null or empty." + $"The parameter '{nameof(propName)}' must not be null or empty to set the property value"); } @@ -240,9 +243,9 @@ public static void SetPropValue(this TObj obj, string propName if (foundProp is null) { - throw new AssertActualExpectedException( - "To exist.", - "Does not exit.", + throw new AssertionFailedException( + "Expected: To exist." + + "\nActual: Does not exit." + $"A property with the name '{propName}' does not exit in the given '{nameof(obj)}' parameter"); } @@ -252,10 +255,10 @@ public static void SetPropValue(this TObj obj, string propName } catch (Exception e) { - throw new AssertActualExpectedException( - $"Property '{propName}' value to be set.", - $"Property '{propName}' value was not set.", - $"Something went wrong with setting the property '{propName}' value in the '{obj}' parameter.\n{e.Message}"); + throw new AssertionFailedException( + $"Expected: Property '{propName}' value to be set." + + $"\nActual: Property '{propName}' value was not set." + + $"\nSomething went wrong with setting the property '{propName}' value in the '{obj}' parameter.\n{e.Message}"); } } } diff --git a/Testing/VersionMinerTests/VersionMinerTests.csproj b/Testing/VersionMinerTests/VersionMinerTests.csproj index b75a43e..2b7329e 100644 --- a/Testing/VersionMinerTests/VersionMinerTests.csproj +++ b/Testing/VersionMinerTests/VersionMinerTests.csproj @@ -1,8 +1,8 @@ - net7.0 - 11.0 + net8.0 + 12.0 enable enable false diff --git a/VersionMiner/VersionMiner.csproj b/VersionMiner/VersionMiner.csproj index 7998561..6933dde 100644 --- a/VersionMiner/VersionMiner.csproj +++ b/VersionMiner/VersionMiner.csproj @@ -2,8 +2,8 @@ Exe - net7.0 - 11.0 + net8.0 + 12.0 enable enable VersionMiner @@ -39,9 +39,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + +