From f086708e37c48bcb223a26bf91929bbaa5af5d3d Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Thu, 8 Aug 2024 15:24:51 +0100 Subject: [PATCH 01/25] Updated Nunit packages and fixed breaking changes --- .../EventGridExplorerLibrary.csproj | 2 +- .../Helpers/ConversionHelperTests.cs | 8 +- .../Helpers/JsonSerializerHelperTest.cs | 14 +- .../Helpers/ServiceBusHelperTest.cs | 24 +- .../Helpers/TwoFilesConfigurationTests.cs | 228 +++++++++--------- .../ServiceBusExplorer.Tests.csproj | 4 +- 6 files changed, 140 insertions(+), 140 deletions(-) diff --git a/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj b/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj index fbc18121..a21d51ef 100644 --- a/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj +++ b/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/ServiceBusExplorer.Tests/Helpers/ConversionHelperTests.cs b/src/ServiceBusExplorer.Tests/Helpers/ConversionHelperTests.cs index e73911b6..d31f6666 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/ConversionHelperTests.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/ConversionHelperTests.cs @@ -18,7 +18,7 @@ public void MapStringTypeToCLRType_ValueIsGuidObject_ReturnsEqualGuidObject() { var guid = new Guid("2E9DB8C4-8803-4BD7-B860-8932CF13835E"); var convertedGuid = ConversionHelper.MapStringTypeToCLRType("Guid", guid); - Assert.AreEqual(guid, convertedGuid); + Assert.That(guid, Is.EqualTo(convertedGuid)); } [Test] @@ -26,7 +26,7 @@ public void MapStringTypeToCLRType_ValueIsGuidString_ReturnsEqualGuidObject() { var guidStr = "2E9DB8C4-8803-4BD7-B860-8932CF13835E"; var convertedGuid = ConversionHelper.MapStringTypeToCLRType("Guid", guidStr); - Assert.AreEqual(guidStr.ToLower(), convertedGuid.ToString()); + Assert.That(guidStr.ToLower(), Is.EqualTo(convertedGuid.ToString())); } [Theory] @@ -37,14 +37,14 @@ public void MapStringTypeToCLRType_ValueIsGuidString_ReturnsEqualGuidObject() public void MapStringTypeToCLRType_ValueIsTimeSpanString_ReturnsEqualTimespanObject(string timespanStr) { var convertedTimespan = ConversionHelper.MapStringTypeToCLRType("TimeSpan", timespanStr); - Assert.AreEqual(convertedTimespan, TimeSpan.Parse(timespanStr, CultureInfo.InvariantCulture)); + Assert.That(convertedTimespan, Is.EqualTo(TimeSpan.Parse(timespanStr, CultureInfo.InvariantCulture))); } [Test] public void MapStringTypeToCLRType_ValueIsTimeSpan_ReturnsEqualTimespanObject() { var convertedTimespan = ConversionHelper.MapStringTypeToCLRType("TimeSpan", TimeSpan.Zero); - Assert.AreEqual(convertedTimespan, TimeSpan.Zero); + Assert.That(convertedTimespan, Is.EqualTo(TimeSpan.Zero)); } } } diff --git a/src/ServiceBusExplorer.Tests/Helpers/JsonSerializerHelperTest.cs b/src/ServiceBusExplorer.Tests/Helpers/JsonSerializerHelperTest.cs index 6ad08d44..ea6600e9 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/JsonSerializerHelperTest.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/JsonSerializerHelperTest.cs @@ -12,7 +12,7 @@ public void IsJson_ReturnsFalse_WhenNullInput() { var result = JsonSerializerHelper.IsJson(null); - Assert.AreEqual(result, false); + Assert.That(result, Is.EqualTo(false)); } [Test] @@ -21,7 +21,7 @@ public void IndentJson_ValueIsNotJson_ReturnsOriginalString() var myOriginalString = "This is a full text string that is not a JSON"; var indented = JsonSerializerHelper.Indent(myOriginalString); - Assert.AreEqual(indented, myOriginalString); + Assert.That(indented, Is.EqualTo(myOriginalString)); } [Test] @@ -30,7 +30,7 @@ public void IndentJson_ValueIsXml_ReturnsOriginalString() var myOriginalString = "XML tileA tile made from some classical XML content."; var indented = JsonSerializerHelper.Indent(myOriginalString); - Assert.AreEqual(indented, myOriginalString); + Assert.That(indented, Is.EqualTo(myOriginalString)); } [Test] @@ -57,7 +57,7 @@ public void IndentJson_ValueIsJson_ReturnsIndentedString() }"; var indented = JsonSerializerHelper.Indent(json); - Assert.AreEqual(indented, expectedResult); + Assert.That(indented, Is.EqualTo(expectedResult)); } [Test] @@ -70,7 +70,7 @@ public void IndentJson_ValueIsJson_DoesNotChangeDateFormat() }"; var indented = JsonSerializerHelper.Indent(json); - Assert.AreEqual(expectedResult, indented); + Assert.That(expectedResult, Is.EqualTo(indented)); } [Test] @@ -80,7 +80,7 @@ public void IndentJson_ValueIsMalformedJson_ReturnsOriginalJson() var expectedResult = @"{""Field1"":""Value1"",""Field1"":""Value2""}"; var indented = JsonSerializerHelper.Indent(json); - Assert.AreEqual(expectedResult, indented); + Assert.That(expectedResult, Is.EqualTo(indented)); } [Test] @@ -98,7 +98,7 @@ public void IndentJson_ValueHasTypeHandling_ReturnsIndentedStringWithTypeHandlin }"; var indented = JsonSerializerHelper.Indent(json); - Assert.AreEqual(indented, expectedResult); + Assert.That(indented, Is.EqualTo(expectedResult)); } } } diff --git a/src/ServiceBusExplorer.Tests/Helpers/ServiceBusHelperTest.cs b/src/ServiceBusExplorer.Tests/Helpers/ServiceBusHelperTest.cs index 7ffdd265..439d31b4 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/ServiceBusHelperTest.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/ServiceBusHelperTest.cs @@ -152,9 +152,9 @@ public void GetMessageText_ProtobufMessage_WindowsAzureServiceApi_ByteArray() var brokeredMessage = new BrokeredMessage(message); var actualMessageText = helper.GetMessageText(brokeredMessage, false, out var actualBodyType); - Assert.AreEqual(expectedBodyType, actualBodyType); - Assert.NotNull(actualMessageText); - Assert.IsFalse(string.IsNullOrWhiteSpace(actualMessageText)); + Assert.That(expectedBodyType, Is.EqualTo(actualBodyType)); + Assert.That(actualMessageText is not null); + Assert.That(!string.IsNullOrWhiteSpace(actualMessageText)); } [Test] @@ -168,9 +168,9 @@ public void GetMessageText_ProtobufMessage_WindowsAzureServiceApi_ReadonlyMemory var brokeredMessage = new BrokeredMessage(message); var actualMessageText = helper.GetMessageText(brokeredMessage, false, out var actualBodyType); - Assert.AreEqual(expectedBodyType, actualBodyType); - Assert.NotNull(actualMessageText); - Assert.IsFalse(string.IsNullOrWhiteSpace(actualMessageText)); + Assert.That(expectedBodyType, Is.EqualTo(actualBodyType)); + Assert.That(actualMessageText is not null); + Assert.That(!string.IsNullOrWhiteSpace(actualMessageText)); } /// @@ -197,16 +197,16 @@ public void GetMessageText_ProtobufMessage_AzureMessagingServiceBus() var brokeredMessage = new BrokeredMessage(new MemoryStream(message)); var actualMessageText = helper.GetMessageText(brokeredMessage, false, out var actualBodyType); - Assert.AreEqual(expectedBodyType, actualBodyType); - Assert.NotNull(actualMessageText); - Assert.IsFalse(string.IsNullOrWhiteSpace(actualMessageText)); + Assert.That(expectedBodyType, Is.EqualTo(actualBodyType)); + Assert.That(actualMessageText is not null); + Assert.That(!string.IsNullOrWhiteSpace(actualMessageText)); } static byte[] CreateProtobufTestMessage() { // Due to incompatibility with .net 462 it is not possible to generate a protobuf message inside the code. - return new byte[] - { + return + [ 10, 12, 8, @@ -293,7 +293,7 @@ static byte[] CreateProtobufTestMessage() 230, 40, 64 - }; + ]; } } } diff --git a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs index 1017b67e..b694256a 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs @@ -9,6 +9,7 @@ using ServiceBusExplorer.Utilities.Helpers; using Microsoft.ServiceBus; using NUnit.Framework; +using System.Linq; namespace ServiceBusExplorer.Tests.Helpers @@ -452,24 +453,24 @@ public void TestMessagingNamespacesReadAndWrite() // Test reading config values - both application config and user config are missing var namespaces = ServiceBusNamespace.GetMessagingNamespaces(configuration, writeToLog); - Assert.AreEqual(0, namespaces.Count); - Assert.IsTrue(logInMemory.Contains("Service bus accounts have not been properly configured")); + Assert.That(0, Is.EqualTo(namespaces.Count)); + Assert.That(logInMemory.Contains("Service bus accounts have not been properly configured")); logInMemory = string.Empty; // Create two connection strings in the user file or the application file depending upon // configFileUse. SaveConnectionString(configuration, IndexNamespaceAdded1); SaveConnectionString(configuration, IndexNamespaceAdded2); - Assert.IsEmpty(logInMemory); + Assert.That(!logInMemory.Any()); namespaces = ServiceBusNamespace.GetMessagingNamespaces (configuration, writeToLog); - Assert.IsEmpty(logInMemory); - Assert.AreEqual(2, namespaces.Count); - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded1].Value, - namespaces[KeyNamespaceAdded1].ConnectionString); - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded2].Value, - namespaces[KeyNamespaceAdded2].ConnectionString); + Assert.That(!logInMemory.Any()); + Assert.That(2, Is.EqualTo(namespaces.Count)); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); // Add a connection to the application config file, but let the two connection @@ -481,19 +482,19 @@ public void TestMessagingNamespacesReadAndWrite() if (UseApplicationConfig(configFileUse)) { - Assert.AreEqual(3, namespaces.Count); - Assert.AreEqual(fakeConnectionStrings[IndexSecondNamespaceInBothFiles].Value, - namespaces[KeyNamespaceInBothFiles].ConnectionString); + Assert.That(3, Is.EqualTo(namespaces.Count)); + Assert.That(fakeConnectionStrings[IndexSecondNamespaceInBothFiles].Value, + Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); } else { - Assert.AreEqual(2, namespaces.Count); + Assert.That(2, Is.EqualTo(namespaces.Count)); } - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded1].Value, - namespaces[KeyNamespaceAdded1].ConnectionString); - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded2].Value, - namespaces[KeyNamespaceAdded2].ConnectionString); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); // Add a connection string to the user file with the same index as an existing entry @@ -505,13 +506,13 @@ public void TestMessagingNamespacesReadAndWrite() configuration= TwoFilesConfiguration.Create(GetUserSettingsFilePath(), configFileUse); namespaces = ServiceBusNamespace.GetMessagingNamespaces(configuration, writeToLog); - Assert.AreEqual(3, namespaces.Count); - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded1].Value, - namespaces[KeyNamespaceAdded1].ConnectionString); - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded2].Value, - namespaces[KeyNamespaceAdded2].ConnectionString); - Assert.AreEqual(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, - namespaces[KeyNamespaceInBothFiles].ConnectionString); + Assert.That(3, Is.EqualTo(namespaces.Count)); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); + Assert.That(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, + Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); // Add a connection string to the application file SaveConnectionStringInApplicationFile(IndexNamespaceInAppFile1); @@ -523,21 +524,21 @@ public void TestMessagingNamespacesReadAndWrite() // two having the same key. if (UseApplicationConfig(configFileUse)) { - Assert.AreEqual(4, namespaces.Count); - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceInAppFile1].Value, - namespaces[KeyNamespaceInAppFile1].ConnectionString); + Assert.That(4, Is.EqualTo(namespaces.Count)); + Assert.That(fakeConnectionStrings[IndexNamespaceInAppFile1].Value, + Is.EqualTo(namespaces[KeyNamespaceInAppFile1].ConnectionString)); } else { - Assert.AreEqual(3, namespaces.Count); + Assert.That(3, Is.EqualTo(namespaces.Count)); } - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded1].Value, - namespaces[KeyNamespaceAdded1].ConnectionString); - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded2].Value, - namespaces[KeyNamespaceAdded2].ConnectionString); - Assert.AreEqual(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, - namespaces[KeyNamespaceInBothFiles].ConnectionString); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); + Assert.That(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, + Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); // Delete the user file so reading will only be from the application file @@ -547,38 +548,38 @@ public void TestMessagingNamespacesReadAndWrite() if (UseApplicationConfig(configFileUse)) { - Assert.IsEmpty(logInMemory); + Assert.That(!logInMemory.Any()); } else { - Assert.IsTrue(logInMemory.Contains("not been properly configured")); + Assert.That(logInMemory.Contains("not been properly configured")); } if (UseApplicationConfig(configFileUse)) { - Assert.AreEqual(configFileUse == ConfigFileUse.ApplicationConfig ? 4 : 2, namespaces.Count); + Assert.That(configFileUse == ConfigFileUse.ApplicationConfig ? 4 : 2, Is.EqualTo(namespaces.Count)); if (configFileUse == ConfigFileUse.ApplicationConfig) { - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded1].Value, - namespaces[KeyNamespaceAdded1].ConnectionString); - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceAdded2].Value, - namespaces[KeyNamespaceAdded2].ConnectionString); - Assert.AreEqual(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, - namespaces[KeyNamespaceInBothFiles].ConnectionString); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); + Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, + Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); + Assert.That(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, + Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); } else { - Assert.AreEqual(fakeConnectionStrings[IndexSecondNamespaceInBothFiles].Value, - namespaces[KeyNamespaceInBothFiles].ConnectionString); + Assert.That(fakeConnectionStrings[IndexSecondNamespaceInBothFiles].Value, + Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); } - Assert.AreEqual(fakeConnectionStrings[IndexNamespaceInAppFile1].Value, - namespaces[KeyNamespaceInAppFile1].ConnectionString); + Assert.That(fakeConnectionStrings[IndexNamespaceInAppFile1].Value, + Is.EqualTo(namespaces[KeyNamespaceInAppFile1].ConnectionString)); } else { - Assert.AreEqual(0, namespaces.Count); + Assert.That(0, Is.EqualTo(namespaces.Count)); } } } @@ -654,10 +655,10 @@ void RemoveNamespaceSectionFromApplicationFile() void SaveConnectionString(TwoFilesConfiguration configuration, int index) { - Assert.IsEmpty(logInMemory); + Assert.That(!logInMemory.Any()); ServiceBusNamespace.SaveConnectionString(configuration, fakeConnectionStrings[index].Key, fakeConnectionStrings[index].Value, writeToLog); - Assert.IsEmpty(logInMemory); + Assert.That(!logInMemory.Any()); } void DeleteUserConfigFile() @@ -671,16 +672,16 @@ void TestReadingBoolValues(TwoFilesConfiguration configuration, bool configHasBe // Get a value that do not exist in the application config file defaulting to true var nonExistingValueAsTrue = configuration.GetBoolValue(KeyDoesNotExistAnywhere, true, writeToLog); - Assert.AreEqual(true, nonExistingValueAsTrue); + Assert.That(true, Is.EqualTo(nonExistingValueAsTrue)); // Get a value that do not exist in the application config file defaulting to false var nonExistingValueAsFalse = configuration.GetBoolValue(KeyDoesNotExistAnywhere, false, writeToLog); - Assert.AreEqual(false, nonExistingValueAsFalse); + Assert.That(false, Is.EqualTo(nonExistingValueAsFalse)); // Get the value from the user file defaulting to true. If userFileShouldHaveUseAsciiKeyAsFalse // is false then we should read from the application config and that value should be true var useAsciiDefTrue = configuration.GetBoolValue(KeyIsInitiallyTrueInAppConfig, true, writeToLog); - Assert.AreEqual(!configHasBeenModified, useAsciiDefTrue); + Assert.That(!configHasBeenModified, Is.EqualTo(useAsciiDefTrue)); // Get a value from that initially only exist in the application file defaulting to false var useAsciiDefFalse = configuration.GetBoolValue(KeyIsInitiallyTrueInAppConfig, false, writeToLog); @@ -695,23 +696,23 @@ void TestReadingBoolValues(TwoFilesConfiguration configuration, bool configHasBe expectedUseAsciiDef = false; } - Assert.AreEqual(expectedUseAsciiDef, useAsciiDefFalse); + Assert.That(expectedUseAsciiDef, Is.EqualTo(useAsciiDefFalse)); // Get a value that does not exist in the user file var savePropertiesToFile = configuration.GetBoolValue(keyOnlyInAppConfig, false, writeToLog); if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.AreEqual(savePropertiesToFile, true); + Assert.That(savePropertiesToFile, Is.EqualTo(true)); } else { - Assert.AreEqual(savePropertiesToFile, false); + Assert.That(savePropertiesToFile, Is.EqualTo(false)); } // Get a value that will only exist in the user file var onlyInUserFile = configuration.GetBoolValue(KeyIsAddedAndSetToTrueBeforeSecondTest, false, writeToLog); - Assert.AreEqual(onlyInUserFile, configHasBeenModified); + Assert.That(onlyInUserFile, Is.EqualTo(configHasBeenModified)); } void TestReadingEnumValues(TwoFilesConfiguration configuration, bool configHasBeenModified) @@ -721,12 +722,12 @@ void TestReadingEnumValues(TwoFilesConfiguration configuration, bool configHasBe // Get a value that do not exist in any of the config files using default var nonExistingValueAsDefault = configuration.GetEnumValue(KeyDoesNotExistAnywhere, default(RelayType), writeToLog); - Assert.AreEqual(RelayType.None, nonExistingValueAsDefault); + Assert.That(RelayType.None, Is.EqualTo(nonExistingValueAsDefault)); // Get a value that do not exist in any of the config files defaulting to false var nonExistingValueAsNetEvent = configuration.GetEnumValue(KeyDoesNotExistAnywhere, RelayType.NetEvent, writeToLog); - Assert.AreEqual(RelayType.NetEvent, nonExistingValueAsNetEvent); + Assert.That(RelayType.NetEvent, Is.EqualTo(nonExistingValueAsNetEvent)); // If configHasBeenModified is false then we should read get the original value which should be // AutoDetect. Otherwise the value is Https. @@ -735,14 +736,14 @@ void TestReadingEnumValues(TwoFilesConfiguration configuration, bool configHasBe if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.AreEqual(configHasBeenModified ? - ConnectivityMode.Https : ConnectivityMode.AutoDetect, connectivityMode); + Assert.That(configHasBeenModified ? + ConnectivityMode.Https : ConnectivityMode.AutoDetect, Is.EqualTo(connectivityMode)); } else // Just user config file { // ConnectivityMode.Http is the default - Assert.AreEqual(configHasBeenModified ? - ConnectivityMode.Https : ConnectivityMode.Http, connectivityMode); + Assert.That(configHasBeenModified ? + ConnectivityMode.Https : ConnectivityMode.Http, Is.EqualTo(connectivityMode)); } // Get a value that do exist initially @@ -751,17 +752,17 @@ void TestReadingEnumValues(TwoFilesConfiguration configuration, bool configHasBe if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.AreEqual(Monster.KingKong, monster); + Assert.That(Monster.KingKong, Is.EqualTo(monster)); } else { - Assert.AreEqual(Monster.Godzilla, monster); + Assert.That(Monster.Godzilla, Is.EqualTo(monster)); } // Get a value that will be added after the first test var crustacean = configuration.GetEnumValue( KeyCrustaceanIsAddedAndSetToCrabBeforeSecondTest, Crustacean.Shrimp, writeToLog); - Assert.AreEqual(configHasBeenModified ? Crustacean.Crab : Crustacean.Shrimp, crustacean); + Assert.That(configHasBeenModified ? Crustacean.Crab : Crustacean.Shrimp, Is.EqualTo(crustacean)); } void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBeenModified) @@ -772,23 +773,23 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee // If the user file exists it should have an invalid value if (configHasBeenModified) { - Assert.IsTrue(configuration.SettingExists(KeyWithInvalidValue)); + Assert.That(configuration.SettingExists(KeyWithInvalidValue)); var shouldBeDefault = configuration.GetIntValue(KeyWithInvalidValue, mediumNumber, writeToLog); - Assert.AreEqual(mediumNumber, shouldBeDefault); - Assert.IsTrue(logInMemory.Contains("which cannot be parsed to a(n) System.Int32")); + Assert.That(mediumNumber, Is.EqualTo(shouldBeDefault)); + Assert.That(logInMemory.Contains("which cannot be parsed to a(n) System.Int32")); logInMemory = string.Empty; } // Get a value that do not exist in any config config file defaulting to empty - Assert.IsFalse(configuration.SettingExists(KeyDoesNotExistAnywhere)); + Assert.That(!configuration.SettingExists(KeyDoesNotExistAnywhere)); var nonExistingValueAsDefault = configuration.GetIntValue(KeyDoesNotExistAnywhere, default, writeToLog); - Assert.AreEqual(0, nonExistingValueAsDefault); + Assert.That(0, Is.EqualTo(nonExistingValueAsDefault)); // Get a value that does not exist in the any config file defaulting to mediumNumber var nonExistingValueAsMediumNumber = configuration.GetIntValue(KeyDoesNotExistAnywhere, mediumNumber, writeToLog); - Assert.AreEqual(mediumNumber, nonExistingValueAsMediumNumber); + Assert.That(mediumNumber, Is.EqualTo(nonExistingValueAsMediumNumber)); // Get the value from the user file defaulting to empty. If configHasBeenModified // is false then we should read from the application config and that value should be @@ -807,7 +808,7 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee expectedLength = configHasBeenModified ? (int)ValueSharkLengthSet172 : default; } - Assert.AreEqual(expectedLength, sharkLength); + Assert.That(expectedLength, Is.EqualTo(sharkLength)); const int largeNumber = 3450242; // Get the value from the user file defaulting to a large number @@ -825,7 +826,7 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee } } - Assert.AreEqual(expectedLength, sharkLength); + Assert.That(expectedLength, Is.EqualTo(sharkLength)); // Get a value that only exists in the application config file const int valueMorayEelLength = 214; @@ -833,11 +834,11 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.AreEqual(valueMorayEelLength, morayEelLength); + Assert.That(valueMorayEelLength, Is.EqualTo(morayEelLength)); } else { - Assert.AreEqual(default(int), morayEelLength); + Assert.That(default(int), Is.EqualTo(morayEelLength)); } // Get a value that will only exist in the user file or overridden in the application file @@ -846,7 +847,7 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee expectedLength = configHasBeenModified ? (int)ValueWhaleLengthSet634 : mediumNumber; - Assert.AreEqual(expectedLength, whaleLengthValue); + Assert.That(expectedLength, Is.EqualTo(whaleLengthValue)); } void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHasBeenModified) @@ -857,12 +858,12 @@ void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHa // Get a value that do not exist in the application config file defaulting to empty var nonExistingValueAsDefault = configuration.GetDecimalValue(KeyDoesNotExistAnywhere, default, writeToLog); - Assert.AreEqual(nonExistingValueAsDefault, 0); + Assert.That(nonExistingValueAsDefault, Is.EqualTo(0)); // Get a value that do not exist in the application config file defaulting to mediumNumber var nonExistingValueAsMediumNumber = configuration.GetDecimalValue (KeyDoesNotExistAnywhere, mediumNumber, writeToLog); - Assert.AreEqual(nonExistingValueAsMediumNumber, mediumNumber); + Assert.That(nonExistingValueAsMediumNumber, Is.EqualTo(mediumNumber)); // If configHasBeenModified is false then we should read from the application config // and that value should be ValueSharkWeightInAppConfig. Get the value from the user @@ -883,7 +884,7 @@ void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHa ValueSharkWeightInUserConfig : default; } - Assert.AreEqual(expectedWeight, sharkWeight); + Assert.That(expectedWeight, Is.EqualTo(sharkWeight)); // Get the value from the user file defaulting to a large number @@ -896,7 +897,7 @@ void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHa expectedWeight = largeNumber; } - Assert.AreEqual(expectedWeight, sharkWeight); + Assert.That(expectedWeight, Is.EqualTo(sharkWeight)); // Get a value that do not exist in the user file const decimal morayEelWeightInAppConfig = 588M; @@ -913,13 +914,13 @@ void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHa expectedMorayEelWeight = default; } - Assert.AreEqual(expectedMorayEelWeight, morayEelWeight); + Assert.That(expectedMorayEelWeight, Is.EqualTo(morayEelWeight)); // Get a value that does not exist in the application config initially var onlyInUserFile = configuration.GetDecimalValue(KeyWhaleWeightWillBeAddedBeforeSecondRun, mediumNumber, writeToLog); expectedWeight = configHasBeenModified ? ValueWhaleWeight8039And30 : mediumNumber; - Assert.AreEqual(expectedWeight, onlyInUserFile); + Assert.That(expectedWeight, Is.EqualTo(onlyInUserFile)); } @@ -930,11 +931,11 @@ void TestReadingStringValues(TwoFilesConfiguration configuration, bool configHas // Get a value that do not exist in the application config file defaulting to empty var nonExistingValueAsTrue = configuration.GetStringValue(KeyDoesNotExistAnywhere, string.Empty); - Assert.AreEqual(nonExistingValueAsTrue, string.Empty); + Assert.That(nonExistingValueAsTrue, Is.EqualTo(string.Empty)); // Get a value that do not exist in any config file defaulting to false var nonExistingValueAsFalse = configuration.GetStringValue(KeyDoesNotExistAnywhere, ExtinctShark); - Assert.AreEqual(nonExistingValueAsFalse, ExtinctShark); + Assert.That(nonExistingValueAsFalse, Is.EqualTo(ExtinctShark)); // Get the value from the user file defaulting to empty. If configHasBeenModified // is false then we should read from the application config and that value should be @@ -943,13 +944,13 @@ void TestReadingStringValues(TwoFilesConfiguration configuration, bool configHas if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.AreEqual(configHasBeenModified ? - ValueForOverridingShark : SharkValueInAppConfig, sharkSpecies); + Assert.That(configHasBeenModified ? + ValueForOverridingShark : SharkValueInAppConfig, Is.EqualTo(sharkSpecies)); } else // Just user config { - Assert.AreEqual(configHasBeenModified ? - ValueForOverridingShark : string.Empty, sharkSpecies); + Assert.That(configHasBeenModified ? + ValueForOverridingShark : string.Empty, Is.EqualTo(sharkSpecies)); } // Get the value from the user file defaulting to false @@ -959,13 +960,13 @@ void TestReadingStringValues(TwoFilesConfiguration configuration, bool configHas if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.AreEqual(configHasBeenModified ? - ValueForOverridingShark : SharkValueInAppConfig, sharkSpecies); + Assert.That(configHasBeenModified ? + ValueForOverridingShark : SharkValueInAppConfig, Is.EqualTo(sharkSpecies)); } else { - Assert.AreEqual(configHasBeenModified ? - ValueForOverridingShark : valueWhiteTipReefShark, sharkSpecies); + Assert.That(configHasBeenModified ? + ValueForOverridingShark : valueWhiteTipReefShark, Is.EqualTo(sharkSpecies)); } // Get a value that do not exist in the user file @@ -974,17 +975,17 @@ void TestReadingStringValues(TwoFilesConfiguration configuration, bool configHas if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.AreEqual(valueGrayWhale, whale); + Assert.That(valueGrayWhale, Is.EqualTo(whale)); } else { - Assert.AreEqual(string.Empty, whale); + Assert.That(string.Empty, Is.EqualTo(whale)); } // Get a value that will only exist in the user file var onlyInUserFile = configuration.GetStringValue(KeyIsAddedAndSetToTrueBeforeSecondTest, ExtinctShark); - Assert.AreEqual(onlyInUserFile, configHasBeenModified ? AnotherShark : ExtinctShark); + Assert.That(onlyInUserFile, Is.EqualTo(configHasBeenModified ? AnotherShark : ExtinctShark)); } void TestReadingHashtableSection(TwoFilesConfiguration configuration, @@ -992,7 +993,7 @@ void TestReadingHashtableSection(TwoFilesConfiguration configuration, { // Get a value that do not exist in the application config file defaulting to empty var nonExistingSection = configuration.GetHashtableFromSection(KeyDoesNotExistAnywhere); - Assert.AreEqual(nonExistingSection, null); + Assert.That(nonExistingSection, Is.EqualTo(null)); var saltWaterFishes = configuration.GetHashtableFromSection(SectionSaltWaterFishesWhichWillBeMerged); @@ -1002,29 +1003,29 @@ void TestReadingHashtableSection(TwoFilesConfiguration configuration, { if (!configHasBeenModified) { - Assert.AreEqual(2, saltWaterFishes.Count); - Assert.AreEqual(ValueAlaskaPollockOldScientificName, saltWaterFishes["Alaska pollock"]); + Assert.That(2, Is.EqualTo(saltWaterFishes.Count)); + Assert.That(ValueAlaskaPollockOldScientificName, Is.EqualTo(saltWaterFishes["Alaska pollock"])); } else { - Assert.AreEqual(3, saltWaterFishes.Count); - Assert.AreEqual(ValueAlaskaPollockNewScientificName, saltWaterFishes["Alaska pollock"]); - Assert.AreEqual("Scomber scombrus", saltWaterFishes["Atlantic mackerel"]); + Assert.That(3, Is.EqualTo(saltWaterFishes.Count)); + Assert.That(ValueAlaskaPollockNewScientificName, Is.EqualTo(saltWaterFishes["Alaska pollock"])); + Assert.That("Scomber scombrus", Is.EqualTo(saltWaterFishes["Atlantic mackerel"])); } - Assert.AreEqual("Scomber colias", saltWaterFishes["Atlantic chub mackerel"]); + Assert.That("Scomber colias", Is.EqualTo(saltWaterFishes["Atlantic chub mackerel"])); } else { if (!configHasBeenModified) { - Assert.IsNull(saltWaterFishes); + Assert.That(saltWaterFishes , Is.Default); } else { - Assert.AreEqual(2, saltWaterFishes.Count); - Assert.AreEqual("Scomber scombrus", saltWaterFishes["Atlantic mackerel"]); - Assert.AreEqual(ValueAlaskaPollockNewScientificName, saltWaterFishes["Alaska Pollock"]); + Assert.That(2, Is.EqualTo(saltWaterFishes.Count)); + Assert.That("Scomber scombrus", Is.EqualTo(saltWaterFishes["Atlantic mackerel"])); + Assert.That(ValueAlaskaPollockNewScientificName, Is.EqualTo(saltWaterFishes["Alaska Pollock"])); } } @@ -1036,20 +1037,19 @@ void TestReadingHashtableSection(TwoFilesConfiguration configuration, { if (ConfigFileUse.ApplicationConfig == configuration.ConfigFileUse) { - Assert.AreEqual(null, freshWaterFishes); - //Assert.AreEqual(0, freshWaterFishes.Count); + Assert.That(null, Is.EqualTo(freshWaterFishes)); } else { - Assert.AreEqual(null, freshWaterFishes); + Assert.That(null, Is.EqualTo(freshWaterFishes)); } } else { - Assert.AreEqual(3, freshWaterFishes.Count); - Assert.AreEqual("Perca flavescens", freshWaterFishes["Perch"]); - Assert.AreEqual("Sander lucioperca", freshWaterFishes["Zander"]); - Assert.AreEqual("Esox lucius", freshWaterFishes["Pike"]); + Assert.That(3, Is.EqualTo(freshWaterFishes.Count)); + Assert.That("Perca flavescens", Is.EqualTo(freshWaterFishes["Perch"])); + Assert.That("Sander lucioperca", Is.EqualTo(freshWaterFishes["Zander"])); + Assert.That("Esox lucius", Is.EqualTo(freshWaterFishes["Pike"])); } } diff --git a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj index 0424cc9f..52f40681 100644 --- a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj +++ b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj @@ -27,8 +27,8 @@ - - + + From f05f1364ee364ed3f7a208375654e7e3afee4d72 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Fri, 9 Aug 2024 13:24:03 +0100 Subject: [PATCH 02/25] migrate to xunit update build pipeline --- .github/workflows/build-test.yml | 27 +- .../Helpers/ConversionHelperTests.cs | 27 +- .../Helpers/JsonSerializerHelperTest.cs | 35 ++- .../Helpers/ServiceBusHelperTest.cs | 174 ++++++----- .../Helpers/TwoFilesConfigurationTests.cs | 288 ++++++++---------- .../ServiceBusExplorer.Tests.csproj | 8 +- .../ServiceBusExplorer.csproj | 2 + 7 files changed, 279 insertions(+), 282 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index d157828c..2e4e986c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -20,28 +20,16 @@ env: jobs: build_test_publish: name: Build and run unit tests - runs-on: windows-2022 - env: - NUnitVersion: '3.16.3' + runs-on: windows-latest steps: - - name: Install NUnit Console Runner and VS project extension - run: | - Install-Package NUnit.ConsoleRunner -Force -RequiredVersion $env:NUnitVersion - Install-Package NUnit.Extension.VSProjectLoader -Force -RequiredVersion '3.9.0' - - name: Git configuration run: git config --global core.autocrlf false - uses: actions/checkout@v4 - - name: Add MSBuild for VS 2022 to PATH - uses: microsoft/setup-msbuild@v2 - with: - vs-version: '[17.2,18.0)' - - name: Restore NuGet packages working-directory: ${{env.GITHUB_WORKSPACE}} - run: nuget restore $env:SOLUTION_FILE_PATH + run: dotnet restore - name: Show version run: echo "Building version ${{ inputs.release-version }}" @@ -72,15 +60,12 @@ jobs: .\SetVersion -FileName $notificationHubsInfoFile -PropertyName 'AssemblyInformationalVersion' -VersionString ${{env.ReleaseVersion}} - name: Build - run: | - msbuild /m /property:Configuration=${{env.BUILD_CONFIGURATION}},FileVersion=${{env.NUMBER_VERSION}},InformationalVersion=${{inputs.release-version}} ${{env.SOLUTION_FILE_PATH}} + working-directory: ${{env.SOLUTION_FILE_PATH}} + run: dotnet build -c ${{env.BUILD_CONFIGURATION}} /p:FileVersion=${{env.NUMBER_VERSION}} /p:InformationalVersion=${{inputs.release-version}} - name: Run tests - run: | - $process = Start-Process -FilePath "C:\Program Files\PackageManagement\NuGet\Packages\NUnit.ConsoleRunner.$env:NUnitVersion\tools\nunit3-console.exe" -ArgumentList "$env:GITHUB_WORKSPACE\src\ServiceBusExplorer.Tests\ServiceBusExplorer.Tests.csproj", "--config=${{env.BUILD_CONFIGURATION}}" -PassThru - Wait-Process -InputObject $process - Get-Content -Path .\TestResult.xml - if ($process.ExitCode -ne 0) {throw "Unit tests failed (exit code = $($process.ExitCode))" } + working-directory: ${{env.SOLUTION_FILE_PATH}} + run: dotnet test - name: Cache build uses: actions/cache@v3.0.11 diff --git a/src/ServiceBusExplorer.Tests/Helpers/ConversionHelperTests.cs b/src/ServiceBusExplorer.Tests/Helpers/ConversionHelperTests.cs index d31f6666..ea1c62c8 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/ConversionHelperTests.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/ConversionHelperTests.cs @@ -2,49 +2,48 @@ using System; using System.Globalization; -using ServiceBusExplorer.Helpers; using ServiceBusExplorer.Utilities.Helpers; -using NUnit.Framework; +using FluentAssertions; +using Xunit; #endregion namespace ServiceBusExplorer.Tests.Helpers { - [TestFixture] public class ConversionHelperTests { - [Test] + [Fact] public void MapStringTypeToCLRType_ValueIsGuidObject_ReturnsEqualGuidObject() { var guid = new Guid("2E9DB8C4-8803-4BD7-B860-8932CF13835E"); var convertedGuid = ConversionHelper.MapStringTypeToCLRType("Guid", guid); - Assert.That(guid, Is.EqualTo(convertedGuid)); + convertedGuid.Should().BeEquivalentTo(guid); } - [Test] + [Fact] public void MapStringTypeToCLRType_ValueIsGuidString_ReturnsEqualGuidObject() { var guidStr = "2E9DB8C4-8803-4BD7-B860-8932CF13835E"; var convertedGuid = ConversionHelper.MapStringTypeToCLRType("Guid", guidStr); - Assert.That(guidStr.ToLower(), Is.EqualTo(convertedGuid.ToString())); + convertedGuid.ToString().Should().BeEquivalentTo(guidStr); } [Theory] - [TestCase("00:00:00")] - [TestCase("3:44:55")] - [TestCase("03:44:55")] - [TestCase("1:00:00:00.0000000")] // one day + [InlineData("00:00:00")] + [InlineData("3:44:55")] + [InlineData("03:44:55")] + [InlineData("1:00:00:00.0000000")] // one day public void MapStringTypeToCLRType_ValueIsTimeSpanString_ReturnsEqualTimespanObject(string timespanStr) { var convertedTimespan = ConversionHelper.MapStringTypeToCLRType("TimeSpan", timespanStr); - Assert.That(convertedTimespan, Is.EqualTo(TimeSpan.Parse(timespanStr, CultureInfo.InvariantCulture))); + convertedTimespan.Should().BeEquivalentTo(TimeSpan.Parse(timespanStr, CultureInfo.InvariantCulture)); } - [Test] + [Fact] public void MapStringTypeToCLRType_ValueIsTimeSpan_ReturnsEqualTimespanObject() { var convertedTimespan = ConversionHelper.MapStringTypeToCLRType("TimeSpan", TimeSpan.Zero); - Assert.That(convertedTimespan, Is.EqualTo(TimeSpan.Zero)); + convertedTimespan.Should().Be(TimeSpan.Zero); } } } diff --git a/src/ServiceBusExplorer.Tests/Helpers/JsonSerializerHelperTest.cs b/src/ServiceBusExplorer.Tests/Helpers/JsonSerializerHelperTest.cs index ea6600e9..c063fbcd 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/JsonSerializerHelperTest.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/JsonSerializerHelperTest.cs @@ -1,39 +1,38 @@ -using ServiceBusExplorer.Helpers; -using ServiceBusExplorer.Utilities.Helpers; -using NUnit.Framework; +using ServiceBusExplorer.Utilities.Helpers; +using FluentAssertions; +using Xunit; namespace ServiceBusExplorer.Tests.Helpers { - [TestFixture] public class JsonSerializerHelperTest { - [Test] + [Fact] public void IsJson_ReturnsFalse_WhenNullInput() { var result = JsonSerializerHelper.IsJson(null); - Assert.That(result, Is.EqualTo(false)); + result.Should().BeFalse(); } - [Test] + [Fact] public void IndentJson_ValueIsNotJson_ReturnsOriginalString() { var myOriginalString = "This is a full text string that is not a JSON"; var indented = JsonSerializerHelper.Indent(myOriginalString); - Assert.That(indented, Is.EqualTo(myOriginalString)); + indented.Should().Be(myOriginalString); } - [Test] + [Fact] public void IndentJson_ValueIsXml_ReturnsOriginalString() { var myOriginalString = "XML tileA tile made from some classical XML content."; var indented = JsonSerializerHelper.Indent(myOriginalString); - Assert.That(indented, Is.EqualTo(myOriginalString)); + indented.Should().Be(myOriginalString); } - [Test] + [Fact] public void IndentJson_ValueIsJson_ReturnsIndentedString() { var json = "{prop1:\"val1\",prop2:2,\"prop3\":[1, 2, 3],prop4:{subProp1:1,subProp2:\"string\",subProp3:[\"a\",\"b\",\"c\"]}}"; @@ -57,10 +56,10 @@ public void IndentJson_ValueIsJson_ReturnsIndentedString() }"; var indented = JsonSerializerHelper.Indent(json); - Assert.That(indented, Is.EqualTo(expectedResult)); + indented.Should().Be(expectedResult); } - [Test] + [Fact] public void IndentJson_ValueIsJson_DoesNotChangeDateFormat() { var json = @"{""dateIso"":""2018-05-14T00:00:00Z"",""dateMicrosoft"":""/Date(1526256000000)/""}"; @@ -70,20 +69,20 @@ public void IndentJson_ValueIsJson_DoesNotChangeDateFormat() }"; var indented = JsonSerializerHelper.Indent(json); - Assert.That(expectedResult, Is.EqualTo(indented)); + expectedResult.Should().Be(indented); } - [Test] + [Fact] public void IndentJson_ValueIsMalformedJson_ReturnsOriginalJson() { var json = @"{""Field1"":""Value1"",""Field1"":""Value2""}"; var expectedResult = @"{""Field1"":""Value1"",""Field1"":""Value2""}"; var indented = JsonSerializerHelper.Indent(json); - Assert.That(expectedResult, Is.EqualTo(indented)); + expectedResult.Should().Be(indented); } - [Test] + [Fact] public void IndentJson_ValueHasTypeHandling_ReturnsIndentedStringWithTypeHandling() { var json = "{\"$type\":\"MyAwesomeLibrary.MyAwesomeClass\",prop1:1,prop2:2,obj:{\"$type\":\"MyAwesomeLibrary.MyOtherAwesomeClass\",default:true}}"; @@ -98,7 +97,7 @@ public void IndentJson_ValueHasTypeHandling_ReturnsIndentedStringWithTypeHandlin }"; var indented = JsonSerializerHelper.Indent(json); - Assert.That(indented, Is.EqualTo(expectedResult)); + indented.Should().Be(expectedResult); } } } diff --git a/src/ServiceBusExplorer.Tests/Helpers/ServiceBusHelperTest.cs b/src/ServiceBusExplorer.Tests/Helpers/ServiceBusHelperTest.cs index 439d31b4..0f1c6003 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/ServiceBusHelperTest.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/ServiceBusHelperTest.cs @@ -1,147 +1,175 @@ #region Using Directives -using ServiceBusExplorer; using System; -using NUnit.Framework; using Microsoft.ServiceBus.Messaging; using System.IO; +using FluentAssertions; +using Xunit; #endregion namespace ServiceBusExplorer.Tests.Helpers { - [TestFixture] public class ServiceBusHelperTest { - [Test] + [Fact] public void GetAddressRelativeToNamespace_AbsoluteUriUnderNamespace_ReturnsRelativePath() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("sb://aaa.test.com/some/path/segments/name"), Is.EqualTo("some/path/segments/name")); + helper.GetAddressRelativeToNamespace("sb://aaa.test.com/some/path/segments/name").Should().Be("some/path/segments/name"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_AbsoluteUriUnderNamespaceTrailingSlash_ReturnsRelativePathWithTrailingSlash() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("sb://aaa.test.com/some/path/segments/name/"), Is.EqualTo("some/path/segments/name/")); + helper.GetAddressRelativeToNamespace("sb://aaa.test.com/some/path/segments/name/").Should().Be("some/path/segments/name/"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_AbsoluteUriUnderNamespace_Different_Scheme_ReturnsRelativePath() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("http://aaa.test.com/some/path/segments/name"), Is.EqualTo("some/path/segments/name")); + helper.GetAddressRelativeToNamespace("http://aaa.test.com/some/path/segments/name").Should().Be("some/path/segments/name"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_AbsoluteUriUnderNamespace_Different_Scheme_Port_Specified_ReturnsRelativePath() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com:80/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com:80/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("http://aaa.test.com:80/some/path/segments/name"), Is.EqualTo("some/path/segments/name")); + helper.GetAddressRelativeToNamespace("http://aaa.test.com:80/some/path/segments/name").Should().Be("some/path/segments/name"); } - [TestCase(":80", ":81")] - [TestCase(":80", "")] - [TestCase("", ":80")] + [Theory] + [InlineData(":80", ":81")] + [InlineData(":80", "")] + [InlineData("", ":80")] public void GetAddressRelativeToNamespace_AbsoluteUriUnderNamespace_Different_Scheme_Different_Port_ReturnsLastSegment(string namespacePort, string port) { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri($"sb://aaa.test.com{namespacePort}/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri($"sb://aaa.test.com{namespacePort}/") + }; - Assert.That(helper.GetAddressRelativeToNamespace($"http://aaa.test.com{port}/some/path/segments/name"), Is.EqualTo("some/path/segments/name")); + helper.GetAddressRelativeToNamespace($"http://aaa.test.com{port}/some/path/segments/name").Should().Be("some/path/segments/name"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_AbsoluteUriNotUnderNamespace_ReturnsLastSegment() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("sb://bbb.test.com/some/path/segments/name"), Is.EqualTo("name")); + helper.GetAddressRelativeToNamespace("sb://bbb.test.com/some/path/segments/name").Should().Be("name"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_AbsoluteUriNotUnderNamespaceTrailingSlash_ReturnsLastSegmentWithTrailingSlash() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("sb://bbb.test.com/some/path/segments/name/"), Is.EqualTo("name/")); + helper.GetAddressRelativeToNamespace("sb://bbb.test.com/some/path/segments/name/").Should().Be("name/"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_RelativeUriWithMultipleSegments_ReturnsLastSegment() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("some/path/segments/name"), Is.EqualTo("name")); + helper.GetAddressRelativeToNamespace("some/path/segments/name").Should().Be("name"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_RelativeUriWithMultipleSegmentsTrailingSlash_ReturnsLastSegmentWithTrailingSlash() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("some/path/segments/name/"), Is.EqualTo("name/")); + helper.GetAddressRelativeToNamespace("some/path/segments/name/").Should().Be("name/"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_RelativeUriWithSingleSegment_ReturnsSegment() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("name"), Is.EqualTo("name")); + helper.GetAddressRelativeToNamespace("name").Should().Be("name"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_RelativeUriWithSingleSegmentAndTrailingSlash_ReturnsSegment() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("name/"), Is.EqualTo("name/")); + helper.GetAddressRelativeToNamespace("name/").Should().Be("name/"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_Slash_ReturnsSlash() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace("/"), Is.EqualTo("/")); + helper.GetAddressRelativeToNamespace("/").Should().Be("/"); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_Empty_ReturnsEmpty() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace(""), Is.EqualTo("")); + helper.GetAddressRelativeToNamespace("").Should().Be(""); } - [Test] + [Fact] public void GetAddressRelativeToNamespace_Whitespace_ReturnsWhitespace() { - var helper = new ServiceBusHelper((m, a) => { }); - helper.NamespaceUri = new Uri("sb://aaa.test.com/"); + var helper = new ServiceBusHelper((m, a) => { }) + { + NamespaceUri = new Uri("sb://aaa.test.com/") + }; - Assert.That(helper.GetAddressRelativeToNamespace(" "), Is.EqualTo(" ")); + helper.GetAddressRelativeToNamespace(" ").Should().Be(" "); } - [Test] + [Fact] public void GetMessageText_ProtobufMessage_WindowsAzureServiceApi_ByteArray() { var expectedBodyType = BodyType.ByteArray; @@ -152,12 +180,12 @@ public void GetMessageText_ProtobufMessage_WindowsAzureServiceApi_ByteArray() var brokeredMessage = new BrokeredMessage(message); var actualMessageText = helper.GetMessageText(brokeredMessage, false, out var actualBodyType); - Assert.That(expectedBodyType, Is.EqualTo(actualBodyType)); - Assert.That(actualMessageText is not null); - Assert.That(!string.IsNullOrWhiteSpace(actualMessageText)); + expectedBodyType.Should().Be(actualBodyType); + actualMessageText.Should().NotBeNull(); + actualMessageText.Should().NotBeNullOrWhiteSpace(); } - [Test] + [Fact] public void GetMessageText_ProtobufMessage_WindowsAzureServiceApi_ReadonlyMemoryByte() { var expectedBodyType = BodyType.Stream; @@ -168,9 +196,9 @@ public void GetMessageText_ProtobufMessage_WindowsAzureServiceApi_ReadonlyMemory var brokeredMessage = new BrokeredMessage(message); var actualMessageText = helper.GetMessageText(brokeredMessage, false, out var actualBodyType); - Assert.That(expectedBodyType, Is.EqualTo(actualBodyType)); - Assert.That(actualMessageText is not null); - Assert.That(!string.IsNullOrWhiteSpace(actualMessageText)); + expectedBodyType.Should().Be(actualBodyType); + actualMessageText.Should().NotBeNull(); + actualMessageText.Should().NotBeNullOrWhiteSpace(); } /// @@ -186,7 +214,7 @@ public void GetMessageText_ProtobufMessage_WindowsAzureServiceApi_ReadonlyMemory /// a string that a human can read  /// readable string" fffff�(@ /// - [Test] + [Fact] public void GetMessageText_ProtobufMessage_AzureMessagingServiceBus() { var expectedBodyType = BodyType.Stream; @@ -197,9 +225,9 @@ public void GetMessageText_ProtobufMessage_AzureMessagingServiceBus() var brokeredMessage = new BrokeredMessage(new MemoryStream(message)); var actualMessageText = helper.GetMessageText(brokeredMessage, false, out var actualBodyType); - Assert.That(expectedBodyType, Is.EqualTo(actualBodyType)); - Assert.That(actualMessageText is not null); - Assert.That(!string.IsNullOrWhiteSpace(actualMessageText)); + expectedBodyType.Should().Be(actualBodyType); + actualMessageText.Should().NotBeNull(); + actualMessageText.Should().NotBeNullOrWhiteSpace(); } static byte[] CreateProtobufTestMessage() diff --git a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs index b694256a..e7562b44 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs @@ -8,8 +8,9 @@ using ServiceBusExplorer.Helpers; using ServiceBusExplorer.Utilities.Helpers; using Microsoft.ServiceBus; -using NUnit.Framework; using System.Linq; +using FluentAssertions; +using Xunit; namespace ServiceBusExplorer.Tests.Helpers @@ -28,7 +29,6 @@ public enum Crustacean Lobster } - [TestFixture] public class TwoFilesConfigurationTests { #region Constants @@ -147,7 +147,7 @@ public TwoFilesConfigurationTests() #endregion #region Public methods - [SetUp] + //TODO: Refactor Setup public void Setup() { // Reset application config file. It does not work well just making a copy @@ -164,7 +164,7 @@ public void Setup() } - [Test] + [Fact] public void TestBoolValuesReadAndWrite() { foreach (var configFileUse in configFileUses) @@ -201,7 +201,7 @@ public void TestBoolValuesReadAndWrite() } } - [Test] + [Fact] public void TestEnumValuesReadAndWrite() { foreach (var configFileUse in configFileUses) @@ -240,7 +240,7 @@ public void TestEnumValuesReadAndWrite() } } - [Test] + [Fact] public void TestDecimalValuesReadAndWrite() { foreach (var configFileUse in configFileUses) @@ -278,7 +278,7 @@ public void TestDecimalValuesReadAndWrite() } } - [Test] + [Fact] public void TestIntValuesReadAndWrite() { foreach (var configFileUse in configFileUses) @@ -320,7 +320,7 @@ public void TestIntValuesReadAndWrite() } } - [Test] + [Fact] public void TestStringValuesReadAndWrite() { foreach (var configFileUse in configFileUses) @@ -357,7 +357,7 @@ public void TestStringValuesReadAndWrite() } } - [Test] + [Fact] public void TestHashtableSectionReadAndWrite() { const string NonExistingSpecies = "NonexistingSpecies"; @@ -439,7 +439,7 @@ public void TestHashtableSectionReadAndWrite() } } - [Test] + [Fact] public void TestMessagingNamespacesReadAndWrite() { foreach (var configFileUse in configFileUses) @@ -453,24 +453,25 @@ public void TestMessagingNamespacesReadAndWrite() // Test reading config values - both application config and user config are missing var namespaces = ServiceBusNamespace.GetMessagingNamespaces(configuration, writeToLog); - Assert.That(0, Is.EqualTo(namespaces.Count)); - Assert.That(logInMemory.Contains("Service bus accounts have not been properly configured")); + namespaces.Should().BeEmpty(); + + logInMemory.Should().Contain("Service bus accounts have not been properly configured"); logInMemory = string.Empty; // Create two connection strings in the user file or the application file depending upon // configFileUse. SaveConnectionString(configuration, IndexNamespaceAdded1); SaveConnectionString(configuration, IndexNamespaceAdded2); - Assert.That(!logInMemory.Any()); + logInMemory.Should().BeEmpty(); - namespaces = ServiceBusNamespace.GetMessagingNamespaces - (configuration, writeToLog); - Assert.That(!logInMemory.Any()); - Assert.That(2, Is.EqualTo(namespaces.Count)); - Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); - Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); + namespaces = ServiceBusNamespace.GetMessagingNamespaces(configuration, writeToLog); + namespaces.Should().HaveCount(2); + + logInMemory.Should().BeEmpty(); + + + fakeConnectionStrings[IndexNamespaceAdded1].Value.Should().Be(namespaces[KeyNamespaceAdded1].ConnectionString); + fakeConnectionStrings[IndexNamespaceAdded2].Value.Should().Be(namespaces[KeyNamespaceAdded2].ConnectionString); // Add a connection to the application config file, but let the two connection @@ -482,19 +483,16 @@ public void TestMessagingNamespacesReadAndWrite() if (UseApplicationConfig(configFileUse)) { - Assert.That(3, Is.EqualTo(namespaces.Count)); - Assert.That(fakeConnectionStrings[IndexSecondNamespaceInBothFiles].Value, - Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); + namespaces.Should().HaveCount(3); + fakeConnectionStrings[IndexSecondNamespaceInBothFiles].Value.Should().Be(namespaces[KeyNamespaceInBothFiles].ConnectionString); } else { - Assert.That(2, Is.EqualTo(namespaces.Count)); + namespaces.Should().HaveCount(2); } - Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); - Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); + fakeConnectionStrings[IndexNamespaceAdded1].Value.Should().Be(namespaces[KeyNamespaceAdded1].ConnectionString); + fakeConnectionStrings[IndexNamespaceAdded2].Value.Should().Be(namespaces[KeyNamespaceAdded2].ConnectionString); // Add a connection string to the user file with the same index as an existing entry @@ -506,13 +504,11 @@ public void TestMessagingNamespacesReadAndWrite() configuration= TwoFilesConfiguration.Create(GetUserSettingsFilePath(), configFileUse); namespaces = ServiceBusNamespace.GetMessagingNamespaces(configuration, writeToLog); - Assert.That(3, Is.EqualTo(namespaces.Count)); - Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); - Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); - Assert.That(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, - Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); + namespaces.Should().HaveCount(3); + fakeConnectionStrings[IndexNamespaceAdded1].Value.Should().Be(namespaces[KeyNamespaceAdded1].ConnectionString); + fakeConnectionStrings[IndexNamespaceAdded2].Value.Should().Be(namespaces[KeyNamespaceAdded2].ConnectionString); + + fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value.Should().Be(namespaces[KeyNamespaceInBothFiles].ConnectionString); // Add a connection string to the application file SaveConnectionStringInApplicationFile(IndexNamespaceInAppFile1); @@ -524,21 +520,18 @@ public void TestMessagingNamespacesReadAndWrite() // two having the same key. if (UseApplicationConfig(configFileUse)) { - Assert.That(4, Is.EqualTo(namespaces.Count)); - Assert.That(fakeConnectionStrings[IndexNamespaceInAppFile1].Value, - Is.EqualTo(namespaces[KeyNamespaceInAppFile1].ConnectionString)); + namespaces.Should().HaveCount(4); + fakeConnectionStrings[IndexNamespaceInAppFile1].Value.Should().Be(namespaces[KeyNamespaceInAppFile1].ConnectionString); } else { - Assert.That(3, Is.EqualTo(namespaces.Count)); + namespaces.Should().HaveCount(3); } - Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); - Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); - Assert.That(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, - Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); + fakeConnectionStrings[IndexNamespaceAdded1].Value.Should().Be(namespaces[KeyNamespaceAdded1].ConnectionString); + fakeConnectionStrings[IndexNamespaceAdded2].Value.Should().Be(namespaces[KeyNamespaceAdded2].ConnectionString); + + fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value.Should().Be(namespaces[KeyNamespaceInBothFiles].ConnectionString); // Delete the user file so reading will only be from the application file @@ -548,38 +541,33 @@ public void TestMessagingNamespacesReadAndWrite() if (UseApplicationConfig(configFileUse)) { - Assert.That(!logInMemory.Any()); + logInMemory.Should().BeEmpty(); } else { - Assert.That(logInMemory.Contains("not been properly configured")); + logInMemory.Should().Contain("not been properly configured"); } if (UseApplicationConfig(configFileUse)) { - Assert.That(configFileUse == ConfigFileUse.ApplicationConfig ? 4 : 2, Is.EqualTo(namespaces.Count)); + (configFileUse == ConfigFileUse.ApplicationConfig ? 4 : 2).Should().Be(namespaces.Count); if (configFileUse == ConfigFileUse.ApplicationConfig) { - Assert.That(fakeConnectionStrings[IndexNamespaceAdded1].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded1].ConnectionString)); - Assert.That(fakeConnectionStrings[IndexNamespaceAdded2].Value, - Is.EqualTo(namespaces[KeyNamespaceAdded2].ConnectionString)); - Assert.That(fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value, - Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); + fakeConnectionStrings[IndexNamespaceAdded1].Value.Should().Be(namespaces[KeyNamespaceAdded1].ConnectionString); + fakeConnectionStrings[IndexNamespaceAdded2].Value.Should().Be(namespaces[KeyNamespaceAdded2].ConnectionString); + fakeConnectionStrings[IndexFirstNamespaceInBothFiles].Value.Should().Be(namespaces[KeyNamespaceInBothFiles].ConnectionString); } else { - Assert.That(fakeConnectionStrings[IndexSecondNamespaceInBothFiles].Value, - Is.EqualTo(namespaces[KeyNamespaceInBothFiles].ConnectionString)); + fakeConnectionStrings[IndexSecondNamespaceInBothFiles].Value.Should().Be(namespaces[KeyNamespaceInBothFiles].ConnectionString); } - - Assert.That(fakeConnectionStrings[IndexNamespaceInAppFile1].Value, - Is.EqualTo(namespaces[KeyNamespaceInAppFile1].ConnectionString)); + + fakeConnectionStrings[IndexNamespaceInAppFile1].Value.Should().Be(namespaces[KeyNamespaceInAppFile1].ConnectionString); } else { - Assert.That(0, Is.EqualTo(namespaces.Count)); + namespaces.Should().BeEmpty(); } } } @@ -655,10 +643,9 @@ void RemoveNamespaceSectionFromApplicationFile() void SaveConnectionString(TwoFilesConfiguration configuration, int index) { - Assert.That(!logInMemory.Any()); - ServiceBusNamespace.SaveConnectionString(configuration, fakeConnectionStrings[index].Key, - fakeConnectionStrings[index].Value, writeToLog); - Assert.That(!logInMemory.Any()); + logInMemory.Should().BeEmpty(); + ServiceBusNamespace.SaveConnectionString(configuration, fakeConnectionStrings[index].Key, fakeConnectionStrings[index].Value, writeToLog); + logInMemory.Should().BeEmpty(); } void DeleteUserConfigFile() @@ -672,16 +659,17 @@ void TestReadingBoolValues(TwoFilesConfiguration configuration, bool configHasBe // Get a value that do not exist in the application config file defaulting to true var nonExistingValueAsTrue = configuration.GetBoolValue(KeyDoesNotExistAnywhere, true, writeToLog); - Assert.That(true, Is.EqualTo(nonExistingValueAsTrue)); + true.Should().Be(nonExistingValueAsTrue); // Get a value that do not exist in the application config file defaulting to false var nonExistingValueAsFalse = configuration.GetBoolValue(KeyDoesNotExistAnywhere, false, writeToLog); - Assert.That(false, Is.EqualTo(nonExistingValueAsFalse)); + false.Should().Be(nonExistingValueAsFalse); // Get the value from the user file defaulting to true. If userFileShouldHaveUseAsciiKeyAsFalse // is false then we should read from the application config and that value should be true var useAsciiDefTrue = configuration.GetBoolValue(KeyIsInitiallyTrueInAppConfig, true, writeToLog); - Assert.That(!configHasBeenModified, Is.EqualTo(useAsciiDefTrue)); + + configHasBeenModified.Should().NotBe(useAsciiDefTrue); // Get a value from that initially only exist in the application file defaulting to false var useAsciiDefFalse = configuration.GetBoolValue(KeyIsInitiallyTrueInAppConfig, false, writeToLog); @@ -696,23 +684,23 @@ void TestReadingBoolValues(TwoFilesConfiguration configuration, bool configHasBe expectedUseAsciiDef = false; } - Assert.That(expectedUseAsciiDef, Is.EqualTo(useAsciiDefFalse)); + expectedUseAsciiDef.Should().Be(useAsciiDefFalse); // Get a value that does not exist in the user file var savePropertiesToFile = configuration.GetBoolValue(keyOnlyInAppConfig, false, writeToLog); if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.That(savePropertiesToFile, Is.EqualTo(true)); + savePropertiesToFile.Should().BeTrue(); } else { - Assert.That(savePropertiesToFile, Is.EqualTo(false)); + savePropertiesToFile.Should().BeFalse(); } // Get a value that will only exist in the user file var onlyInUserFile = configuration.GetBoolValue(KeyIsAddedAndSetToTrueBeforeSecondTest, false, writeToLog); - Assert.That(onlyInUserFile, Is.EqualTo(configHasBeenModified)); + onlyInUserFile.Should().Be(configHasBeenModified); } void TestReadingEnumValues(TwoFilesConfiguration configuration, bool configHasBeenModified) @@ -720,30 +708,27 @@ void TestReadingEnumValues(TwoFilesConfiguration configuration, bool configHasBe const string keyOnlyInAppConfig = "monster"; // Get a value that do not exist in any of the config files using default - var nonExistingValueAsDefault = configuration.GetEnumValue(KeyDoesNotExistAnywhere, - default(RelayType), writeToLog); - Assert.That(RelayType.None, Is.EqualTo(nonExistingValueAsDefault)); + var nonExistingValueAsDefault = configuration.GetEnumValue(KeyDoesNotExistAnywhere, default(RelayType), writeToLog); + + RelayType.None.Should().Be(nonExistingValueAsDefault); // Get a value that do not exist in any of the config files defaulting to false - var nonExistingValueAsNetEvent = configuration.GetEnumValue(KeyDoesNotExistAnywhere, - RelayType.NetEvent, writeToLog); - Assert.That(RelayType.NetEvent, Is.EqualTo(nonExistingValueAsNetEvent)); + var nonExistingValueAsNetEvent = configuration.GetEnumValue(KeyDoesNotExistAnywhere, RelayType.NetEvent, writeToLog); + + RelayType.NetEvent.Should().Be(nonExistingValueAsNetEvent); // If configHasBeenModified is false then we should read get the original value which should be // AutoDetect. Otherwise the value is Https. - var connectivityMode = configuration.GetEnumValue - (KeyConnectivityModeWhichWillBeOverriddenOrOverwritten, default, writeToLog); + var connectivityMode = configuration.GetEnumValue(KeyConnectivityModeWhichWillBeOverriddenOrOverwritten, default, writeToLog); if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.That(configHasBeenModified ? - ConnectivityMode.Https : ConnectivityMode.AutoDetect, Is.EqualTo(connectivityMode)); + (configHasBeenModified ? ConnectivityMode.Https : ConnectivityMode.AutoDetect).Should().Be(connectivityMode); } else // Just user config file { // ConnectivityMode.Http is the default - Assert.That(configHasBeenModified ? - ConnectivityMode.Https : ConnectivityMode.Http, Is.EqualTo(connectivityMode)); + (configHasBeenModified ? ConnectivityMode.Https : ConnectivityMode.Http).Should().Be(connectivityMode); } // Get a value that do exist initially @@ -752,17 +737,17 @@ void TestReadingEnumValues(TwoFilesConfiguration configuration, bool configHasBe if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.That(Monster.KingKong, Is.EqualTo(monster)); + monster.Should().Be(Monster.KingKong); } else { - Assert.That(Monster.Godzilla, Is.EqualTo(monster)); + monster.Should().Be(Monster.Godzilla); } // Get a value that will be added after the first test - var crustacean = configuration.GetEnumValue( - KeyCrustaceanIsAddedAndSetToCrabBeforeSecondTest, Crustacean.Shrimp, writeToLog); - Assert.That(configHasBeenModified ? Crustacean.Crab : Crustacean.Shrimp, Is.EqualTo(crustacean)); + var crustacean = configuration.GetEnumValue(KeyCrustaceanIsAddedAndSetToCrabBeforeSecondTest, Crustacean.Shrimp, writeToLog); + + (configHasBeenModified ? Crustacean.Crab : Crustacean.Shrimp).Should().Be(crustacean); } void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBeenModified) @@ -773,23 +758,26 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee // If the user file exists it should have an invalid value if (configHasBeenModified) { - Assert.That(configuration.SettingExists(KeyWithInvalidValue)); + configuration.SettingExists(KeyWithInvalidValue).Should().BeTrue(); + var shouldBeDefault = configuration.GetIntValue(KeyWithInvalidValue, mediumNumber, writeToLog); - Assert.That(mediumNumber, Is.EqualTo(shouldBeDefault)); - Assert.That(logInMemory.Contains("which cannot be parsed to a(n) System.Int32")); + + mediumNumber.Should().Be(shouldBeDefault); + + logInMemory.Should().Contain("which cannot be parsed to a(n) System.Int32"); logInMemory = string.Empty; } // Get a value that do not exist in any config config file defaulting to empty - Assert.That(!configuration.SettingExists(KeyDoesNotExistAnywhere)); - var nonExistingValueAsDefault = configuration.GetIntValue(KeyDoesNotExistAnywhere, - default, writeToLog); - Assert.That(0, Is.EqualTo(nonExistingValueAsDefault)); + configuration.SettingExists(KeyDoesNotExistAnywhere).Should().BeFalse(); + var nonExistingValueAsDefault = configuration.GetIntValue(KeyDoesNotExistAnywhere, default, writeToLog); + + nonExistingValueAsDefault.Should().Be(0); // Get a value that does not exist in the any config file defaulting to mediumNumber - var nonExistingValueAsMediumNumber = configuration.GetIntValue(KeyDoesNotExistAnywhere, - mediumNumber, writeToLog); - Assert.That(mediumNumber, Is.EqualTo(nonExistingValueAsMediumNumber)); + var nonExistingValueAsMediumNumber = configuration.GetIntValue(KeyDoesNotExistAnywhere, mediumNumber, writeToLog); + + mediumNumber.Should().Be(nonExistingValueAsMediumNumber); // Get the value from the user file defaulting to empty. If configHasBeenModified // is false then we should read from the application config and that value should be @@ -800,15 +788,14 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee if (UseApplicationConfig(configuration.ConfigFileUse)) { - expectedLength = configHasBeenModified ? - (int)ValueSharkLengthSet172 : (int)ValueSharkLengthInitial158; + expectedLength = configHasBeenModified ? (int)ValueSharkLengthSet172 : (int)ValueSharkLengthInitial158; } else // Just user config { expectedLength = configHasBeenModified ? (int)ValueSharkLengthSet172 : default; } - Assert.That(expectedLength, Is.EqualTo(sharkLength)); + expectedLength.Should().Be(sharkLength); const int largeNumber = 3450242; // Get the value from the user file defaulting to a large number @@ -826,7 +813,7 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee } } - Assert.That(expectedLength, Is.EqualTo(sharkLength)); + expectedLength.Should().Be(sharkLength); // Get a value that only exists in the application config file const int valueMorayEelLength = 214; @@ -834,11 +821,11 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.That(valueMorayEelLength, Is.EqualTo(morayEelLength)); + valueMorayEelLength.Should().Be(morayEelLength); } else { - Assert.That(default(int), Is.EqualTo(morayEelLength)); + morayEelLength.Should().Be(default); } // Get a value that will only exist in the user file or overridden in the application file @@ -847,7 +834,7 @@ void TestReadingIntValues(TwoFilesConfiguration configuration, bool configHasBee expectedLength = configHasBeenModified ? (int)ValueWhaleLengthSet634 : mediumNumber; - Assert.That(expectedLength, Is.EqualTo(whaleLengthValue)); + expectedLength.Should().Be(whaleLengthValue); } void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHasBeenModified) @@ -856,35 +843,32 @@ void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHa const decimal mediumNumber = 52.88M; // Get a value that do not exist in the application config file defaulting to empty - var nonExistingValueAsDefault = configuration.GetDecimalValue(KeyDoesNotExistAnywhere, default, - writeToLog); - Assert.That(nonExistingValueAsDefault, Is.EqualTo(0)); + var nonExistingValueAsDefault = configuration.GetDecimalValue(KeyDoesNotExistAnywhere, default, writeToLog); + + nonExistingValueAsDefault.Should().Be(0); // Get a value that do not exist in the application config file defaulting to mediumNumber - var nonExistingValueAsMediumNumber = configuration.GetDecimalValue - (KeyDoesNotExistAnywhere, mediumNumber, writeToLog); - Assert.That(nonExistingValueAsMediumNumber, Is.EqualTo(mediumNumber)); + var nonExistingValueAsMediumNumber = configuration.GetDecimalValue(KeyDoesNotExistAnywhere, mediumNumber, writeToLog); + + nonExistingValueAsMediumNumber.Should().Be(mediumNumber); // If configHasBeenModified is false then we should read from the application config // and that value should be ValueSharkWeightInAppConfig. Get the value from the user // file defaulting to empty. - var sharkWeight = configuration.GetDecimalValue(KeySharkWeightWhichWillBeOverridden, - default, writeToLog); + var sharkWeight = configuration.GetDecimalValue(KeySharkWeightWhichWillBeOverridden, default, writeToLog); decimal expectedWeight; if (UseApplicationConfig(configuration.ConfigFileUse)) { - expectedWeight = configHasBeenModified ? - ValueSharkWeightInUserConfig : ValueSharkWeightInAppConfig; + expectedWeight = configHasBeenModified ? ValueSharkWeightInUserConfig : ValueSharkWeightInAppConfig; } else { - expectedWeight = configHasBeenModified ? - ValueSharkWeightInUserConfig : default; + expectedWeight = configHasBeenModified ? ValueSharkWeightInUserConfig : default; } - Assert.That(expectedWeight, Is.EqualTo(sharkWeight)); + expectedWeight.Should().Be(sharkWeight); // Get the value from the user file defaulting to a large number @@ -897,7 +881,7 @@ void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHa expectedWeight = largeNumber; } - Assert.That(expectedWeight, Is.EqualTo(sharkWeight)); + expectedWeight.Should().Be(sharkWeight); // Get a value that do not exist in the user file const decimal morayEelWeightInAppConfig = 588M; @@ -914,13 +898,13 @@ void TestReadingDecimalValues(TwoFilesConfiguration configuration, bool configHa expectedMorayEelWeight = default; } - Assert.That(expectedMorayEelWeight, Is.EqualTo(morayEelWeight)); + expectedMorayEelWeight.Should().Be(morayEelWeight); // Get a value that does not exist in the application config initially var onlyInUserFile = configuration.GetDecimalValue(KeyWhaleWeightWillBeAddedBeforeSecondRun, mediumNumber, writeToLog); expectedWeight = configHasBeenModified ? ValueWhaleWeight8039And30 : mediumNumber; - Assert.That(expectedWeight, Is.EqualTo(onlyInUserFile)); + expectedWeight.Should().Be(onlyInUserFile); } @@ -931,11 +915,11 @@ void TestReadingStringValues(TwoFilesConfiguration configuration, bool configHas // Get a value that do not exist in the application config file defaulting to empty var nonExistingValueAsTrue = configuration.GetStringValue(KeyDoesNotExistAnywhere, string.Empty); - Assert.That(nonExistingValueAsTrue, Is.EqualTo(string.Empty)); + nonExistingValueAsTrue.Should().BeEmpty(); // Get a value that do not exist in any config file defaulting to false var nonExistingValueAsFalse = configuration.GetStringValue(KeyDoesNotExistAnywhere, ExtinctShark); - Assert.That(nonExistingValueAsFalse, Is.EqualTo(ExtinctShark)); + nonExistingValueAsFalse.Should().Be(ExtinctShark); // Get the value from the user file defaulting to empty. If configHasBeenModified // is false then we should read from the application config and that value should be @@ -944,13 +928,11 @@ void TestReadingStringValues(TwoFilesConfiguration configuration, bool configHas if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.That(configHasBeenModified ? - ValueForOverridingShark : SharkValueInAppConfig, Is.EqualTo(sharkSpecies)); + (configHasBeenModified ? ValueForOverridingShark : SharkValueInAppConfig).Should().Be(sharkSpecies); } else // Just user config { - Assert.That(configHasBeenModified ? - ValueForOverridingShark : string.Empty, Is.EqualTo(sharkSpecies)); + (configHasBeenModified ? ValueForOverridingShark : string.Empty).Should().Be(sharkSpecies); } // Get the value from the user file defaulting to false @@ -960,13 +942,11 @@ void TestReadingStringValues(TwoFilesConfiguration configuration, bool configHas if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.That(configHasBeenModified ? - ValueForOverridingShark : SharkValueInAppConfig, Is.EqualTo(sharkSpecies)); + (configHasBeenModified ? ValueForOverridingShark : SharkValueInAppConfig).Should().Be(sharkSpecies); } else { - Assert.That(configHasBeenModified ? - ValueForOverridingShark : valueWhiteTipReefShark, Is.EqualTo(sharkSpecies)); + (configHasBeenModified ? ValueForOverridingShark : valueWhiteTipReefShark).Should().Be(sharkSpecies); } // Get a value that do not exist in the user file @@ -975,17 +955,17 @@ void TestReadingStringValues(TwoFilesConfiguration configuration, bool configHas if (UseApplicationConfig(configuration.ConfigFileUse)) { - Assert.That(valueGrayWhale, Is.EqualTo(whale)); + valueGrayWhale.Should().Be(whale); } else { - Assert.That(string.Empty, Is.EqualTo(whale)); + whale.Should().BeEmpty(); } // Get a value that will only exist in the user file - var onlyInUserFile = configuration.GetStringValue(KeyIsAddedAndSetToTrueBeforeSecondTest, - ExtinctShark); - Assert.That(onlyInUserFile, Is.EqualTo(configHasBeenModified ? AnotherShark : ExtinctShark)); + var onlyInUserFile = configuration.GetStringValue(KeyIsAddedAndSetToTrueBeforeSecondTest, ExtinctShark); + + onlyInUserFile.Should().Be(configHasBeenModified ? AnotherShark : ExtinctShark); } void TestReadingHashtableSection(TwoFilesConfiguration configuration, @@ -993,7 +973,7 @@ void TestReadingHashtableSection(TwoFilesConfiguration configuration, { // Get a value that do not exist in the application config file defaulting to empty var nonExistingSection = configuration.GetHashtableFromSection(KeyDoesNotExistAnywhere); - Assert.That(nonExistingSection, Is.EqualTo(null)); + nonExistingSection.Should().BeNull(); var saltWaterFishes = configuration.GetHashtableFromSection(SectionSaltWaterFishesWhichWillBeMerged); @@ -1003,29 +983,29 @@ void TestReadingHashtableSection(TwoFilesConfiguration configuration, { if (!configHasBeenModified) { - Assert.That(2, Is.EqualTo(saltWaterFishes.Count)); - Assert.That(ValueAlaskaPollockOldScientificName, Is.EqualTo(saltWaterFishes["Alaska pollock"])); + saltWaterFishes.Count.Should().Be(2); + saltWaterFishes["Alaska pollock"].Should().Be(ValueAlaskaPollockOldScientificName); } else { - Assert.That(3, Is.EqualTo(saltWaterFishes.Count)); - Assert.That(ValueAlaskaPollockNewScientificName, Is.EqualTo(saltWaterFishes["Alaska pollock"])); - Assert.That("Scomber scombrus", Is.EqualTo(saltWaterFishes["Atlantic mackerel"])); + saltWaterFishes.Count.Should().Be(3); + saltWaterFishes["Alaska pollock"].Should().Be(ValueAlaskaPollockNewScientificName); + saltWaterFishes["Atlantic mackerel"].Should().Be("Scomber scombrus"); } - Assert.That("Scomber colias", Is.EqualTo(saltWaterFishes["Atlantic chub mackerel"])); + saltWaterFishes["Atlantic chub mackerel"].Should().Be("Scomber colias"); } else { if (!configHasBeenModified) { - Assert.That(saltWaterFishes , Is.Default); + saltWaterFishes.Should().BeNull(); } else { - Assert.That(2, Is.EqualTo(saltWaterFishes.Count)); - Assert.That("Scomber scombrus", Is.EqualTo(saltWaterFishes["Atlantic mackerel"])); - Assert.That(ValueAlaskaPollockNewScientificName, Is.EqualTo(saltWaterFishes["Alaska Pollock"])); + saltWaterFishes.Count.Should().Be(2); + saltWaterFishes["Atlantic mackerel"].Should().Be("Scomber scombrus"); + saltWaterFishes["Alaska Pollock"].Should().Be(ValueAlaskaPollockNewScientificName); } } @@ -1037,19 +1017,19 @@ void TestReadingHashtableSection(TwoFilesConfiguration configuration, { if (ConfigFileUse.ApplicationConfig == configuration.ConfigFileUse) { - Assert.That(null, Is.EqualTo(freshWaterFishes)); + freshWaterFishes.Should().BeNull(); } else { - Assert.That(null, Is.EqualTo(freshWaterFishes)); + freshWaterFishes.Should().BeNull(); } } else { - Assert.That(3, Is.EqualTo(freshWaterFishes.Count)); - Assert.That("Perca flavescens", Is.EqualTo(freshWaterFishes["Perch"])); - Assert.That("Sander lucioperca", Is.EqualTo(freshWaterFishes["Zander"])); - Assert.That("Esox lucius", Is.EqualTo(freshWaterFishes["Pike"])); + freshWaterFishes.Count.Should().Be(3); + freshWaterFishes["Perch"].Should().Be("Perca flavescens"); + freshWaterFishes["Zander"].Should().Be("Sander lucioperca"); + freshWaterFishes["Pike"].Should().Be("Esox lucius"); } } diff --git a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj index 52f40681..cc4df90e 100644 --- a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj +++ b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj @@ -27,8 +27,12 @@ - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/ServiceBusExplorer/ServiceBusExplorer.csproj b/src/ServiceBusExplorer/ServiceBusExplorer.csproj index 2d937bfd..a6eb5beb 100644 --- a/src/ServiceBusExplorer/ServiceBusExplorer.csproj +++ b/src/ServiceBusExplorer/ServiceBusExplorer.csproj @@ -24,6 +24,7 @@ false false true + true 8 Service Bus Explorer Paolo Salvatori @@ -549,6 +550,7 @@ + From c70d8c4f58b7d513294523df14499c1c5213f7bf Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Fri, 9 Aug 2024 13:28:34 +0100 Subject: [PATCH 03/25] fix working path for dotnet restore --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 2e4e986c..c5987b89 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v4 - name: Restore NuGet packages - working-directory: ${{env.GITHUB_WORKSPACE}} + working-directory: ${{env.SOLUTION_FILE_PATH}} run: dotnet restore - name: Show version From 8a06267818362e23930f677b30f23792030e16b0 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Fri, 9 Aug 2024 13:36:39 +0100 Subject: [PATCH 04/25] use release version as environment variable --- .github/workflows/build-test.yml | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index c5987b89..96b52c5b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -38,34 +38,18 @@ jobs: env: ReleaseVersion: ${{ inputs.release-version }} run: | - $numberVersion = .\GetNumberVersion -Version ${{env.ReleaseVersion}} + Write-Host "Using release version: $env:ReleaseVersion" + $numberVersion = .\GetNumberVersion -Version $env:ReleaseVersion echo "Setting numberVersion to $numberVersion" echo "NUMBER_VERSION=$numberVersion" >> $env:GITHUB_ENV - - name: Set fileversion on all .NET Framework assemblies and assembly version on the exe - env: - ReleaseVersion: ${{ inputs.release-version }} - run: | - $sbeFileName = "$env:GITHUB_WORKSPACE\src\ServiceBusExplorer\Properties\AssemblyInfo.cs" - .\SetVersion -FileName $sbeFileName -PropertyName 'AssemblyVersion' -Version ${{env.NUMBER_VERSION}} - .\SetVersion -FileName $sbeFileName -PropertyName 'AssemblyFileVersion' -Version ${{env.NUMBER_VERSION}} - .\SetVersion -FileName $sbeFileName -PropertyName 'AssemblyInformationalVersion' -VersionString ${{env.ReleaseVersion}} - - $commonInfoFile = "$env:GITHUB_WORKSPACE\src\Common\Properties\AssemblyInfo.cs" - .\SetVersion -FileName $commonInfoFile -PropertyName 'AssemblyFileVersion' -Version ${{env.NUMBER_VERSION}} - .\SetVersion -FileName $commonInfoFile -PropertyName 'AssemblyInformationalVersion' -VersionString ${{env.ReleaseVersion}} - - $notificationHubsInfoFile = "$env:GITHUB_WORKSPACE\src\NotificationHubs\Properties\AssemblyInfo.cs" - .\SetVersion -FileName $notificationHubsInfoFile -PropertyName 'AssemblyFileVersion' -Version ${{env.NUMBER_VERSION}} - .\SetVersion -FileName $notificationHubsInfoFile -PropertyName 'AssemblyInformationalVersion' -VersionString ${{env.ReleaseVersion}} - - name: Build working-directory: ${{env.SOLUTION_FILE_PATH}} - run: dotnet build -c ${{env.BUILD_CONFIGURATION}} /p:FileVersion=${{env.NUMBER_VERSION}} /p:InformationalVersion=${{inputs.release-version}} + run: dotnet build -c ${{env.BUILD_CONFIGURATION}} /p:AssemblyVersion=${{env.NUMBER_VERSION}} /p:InformationalVersion=${{inputs.release-version}} - name: Run tests working-directory: ${{env.SOLUTION_FILE_PATH}} - run: dotnet test + run: dotnet test -c ${{env.BUILD_CONFIGURATION}} - name: Cache build uses: actions/cache@v3.0.11 From 16d626c57bb2ca5b0f6e07afee8d5b2f6f0cc797 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Fri, 9 Aug 2024 13:50:00 +0100 Subject: [PATCH 05/25] use default value for release version on feature branch --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 96b52c5b..50f49c1d 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: release-version: - required: true + required: false type: string default: '0.0.0' cache-build: From 10cae547323fd586197dbd598c9125963dc19d0f Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Fri, 9 Aug 2024 13:55:11 +0100 Subject: [PATCH 06/25] add input to workflow dispatch --- .github/workflows/build-test.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 50f49c1d..95eafbfb 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -4,7 +4,7 @@ on: workflow_call: inputs: release-version: - required: false + required: true type: string default: '0.0.0' cache-build: @@ -12,7 +12,11 @@ on: type: boolean default: false workflow_dispatch: - + inputs: + release-version: + required: false + type: string + default: '0.0.0' env: SOLUTION_FILE_PATH: .\src BUILD_CONFIGURATION: Release From 80c401099404372b78aac9128a978b6341cd2454 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Fri, 9 Aug 2024 14:05:42 +0100 Subject: [PATCH 07/25] use latest system.resources package --- .github/workflows/build-test.yml | 1 - src/ServiceBusExplorer/ServiceBusExplorer.csproj | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 95eafbfb..de513776 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -6,7 +6,6 @@ on: release-version: required: true type: string - default: '0.0.0' cache-build: required: false type: boolean diff --git a/src/ServiceBusExplorer/ServiceBusExplorer.csproj b/src/ServiceBusExplorer/ServiceBusExplorer.csproj index a6eb5beb..99943066 100644 --- a/src/ServiceBusExplorer/ServiceBusExplorer.csproj +++ b/src/ServiceBusExplorer/ServiceBusExplorer.csproj @@ -24,7 +24,7 @@ false false true - true + true 8 Service Bus Explorer Paolo Salvatori @@ -550,7 +550,7 @@ - + From ff4277965b13c095928fb70734551c7b9ecab000 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Fri, 9 Aug 2024 14:22:23 +0100 Subject: [PATCH 08/25] resolve some of the pending todo tasks --- .../Helpers/TwoFilesConfigurationTests.cs | 3 +-- src/ServiceBusExplorer/Controls/TrackBar.cs | 6 ------ .../UIHelpers/CustomPropertyDescriptor.cs | 18 +++--------------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs index e7562b44..8d085e28 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs @@ -147,8 +147,7 @@ public TwoFilesConfigurationTests() #endregion #region Public methods - //TODO: Refactor Setup - public void Setup() + private void Setup() { // Reset application config file. It does not work well just making a copy // of the application config file since it may have been modified by a previous diff --git a/src/ServiceBusExplorer/Controls/TrackBar.cs b/src/ServiceBusExplorer/Controls/TrackBar.cs index 840cdfe3..e5ee123c 100644 --- a/src/ServiceBusExplorer/Controls/TrackBar.cs +++ b/src/ServiceBusExplorer/Controls/TrackBar.cs @@ -627,9 +627,6 @@ public int Minimum if (minimum > maximum) maximum = minimum; - if (minimum > value) - // ReSharper disable once RedundantAssignment - value = minimum; // TODO: this is off... if(autoSize) Size = FitSize; @@ -651,9 +648,6 @@ public int Maximum { maximum = value; - if (maximum < value) - // ReSharper disable once RedundantAssignment - value = maximum; // TODO: this is off.. if (maximum < minimum) minimum = maximum; diff --git a/src/ServiceBusExplorer/UIHelpers/CustomPropertyDescriptor.cs b/src/ServiceBusExplorer/UIHelpers/CustomPropertyDescriptor.cs index a0053fd4..2173ef2b 100644 --- a/src/ServiceBusExplorer/UIHelpers/CustomPropertyDescriptor.cs +++ b/src/ServiceBusExplorer/UIHelpers/CustomPropertyDescriptor.cs @@ -236,21 +236,9 @@ public override bool IsLocalizable public object DefaultValue { - get - { - var attr = (DefaultValueAttribute)attributes.FirstOrDefault(a => a is DefaultValueAttribute); - return attr != null ? attr.Value : null; - } - set - { - var attr = (DefaultValueAttribute)attributes.FirstOrDefault(a => a is DefaultValueAttribute); - if (attr == null) - { - attributes.RemoveAll(a => a is DefaultValueAttribute); - } - // ReSharper disable once RedundantAssignment - attr = new DefaultValueAttribute(value); // TODO: what's this doing? - } + get => attributes.OfType().FirstOrDefault()?.Value; + + set => value = (DefaultValueAttribute)attributes.FirstOrDefault(a => a is DefaultValueAttribute); } public int PropertyId From b2c0aeedcb061759328c83e42a47834b258f1907 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Mon, 12 Aug 2024 13:00:39 +0100 Subject: [PATCH 09/25] Revert "resolve some of the pending todo tasks" This reverts commit ff4277965b13c095928fb70734551c7b9ecab000. --- .../Helpers/TwoFilesConfigurationTests.cs | 3 ++- src/ServiceBusExplorer/Controls/TrackBar.cs | 6 ++++++ .../UIHelpers/CustomPropertyDescriptor.cs | 18 +++++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs index 8d085e28..e7562b44 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs @@ -147,7 +147,8 @@ public TwoFilesConfigurationTests() #endregion #region Public methods - private void Setup() + //TODO: Refactor Setup + public void Setup() { // Reset application config file. It does not work well just making a copy // of the application config file since it may have been modified by a previous diff --git a/src/ServiceBusExplorer/Controls/TrackBar.cs b/src/ServiceBusExplorer/Controls/TrackBar.cs index e5ee123c..840cdfe3 100644 --- a/src/ServiceBusExplorer/Controls/TrackBar.cs +++ b/src/ServiceBusExplorer/Controls/TrackBar.cs @@ -627,6 +627,9 @@ public int Minimum if (minimum > maximum) maximum = minimum; + if (minimum > value) + // ReSharper disable once RedundantAssignment + value = minimum; // TODO: this is off... if(autoSize) Size = FitSize; @@ -648,6 +651,9 @@ public int Maximum { maximum = value; + if (maximum < value) + // ReSharper disable once RedundantAssignment + value = maximum; // TODO: this is off.. if (maximum < minimum) minimum = maximum; diff --git a/src/ServiceBusExplorer/UIHelpers/CustomPropertyDescriptor.cs b/src/ServiceBusExplorer/UIHelpers/CustomPropertyDescriptor.cs index 2173ef2b..a0053fd4 100644 --- a/src/ServiceBusExplorer/UIHelpers/CustomPropertyDescriptor.cs +++ b/src/ServiceBusExplorer/UIHelpers/CustomPropertyDescriptor.cs @@ -236,9 +236,21 @@ public override bool IsLocalizable public object DefaultValue { - get => attributes.OfType().FirstOrDefault()?.Value; - - set => value = (DefaultValueAttribute)attributes.FirstOrDefault(a => a is DefaultValueAttribute); + get + { + var attr = (DefaultValueAttribute)attributes.FirstOrDefault(a => a is DefaultValueAttribute); + return attr != null ? attr.Value : null; + } + set + { + var attr = (DefaultValueAttribute)attributes.FirstOrDefault(a => a is DefaultValueAttribute); + if (attr == null) + { + attributes.RemoveAll(a => a is DefaultValueAttribute); + } + // ReSharper disable once RedundantAssignment + attr = new DefaultValueAttribute(value); // TODO: what's this doing? + } } public int PropertyId From 9108f85b05c21d6763a352e004faa4ae517478c9 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Mon, 12 Aug 2024 13:15:07 +0100 Subject: [PATCH 10/25] revert changes not related to xunit migration --- .github/workflows/build-test.yml | 2 +- src/ServiceBusExplorer/ServiceBusExplorer.csproj | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index de513776..e04ec5a2 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -23,7 +23,7 @@ env: jobs: build_test_publish: name: Build and run unit tests - runs-on: windows-latest + runs-on: windows-2022 steps: - name: Git configuration run: git config --global core.autocrlf false diff --git a/src/ServiceBusExplorer/ServiceBusExplorer.csproj b/src/ServiceBusExplorer/ServiceBusExplorer.csproj index 99943066..2d937bfd 100644 --- a/src/ServiceBusExplorer/ServiceBusExplorer.csproj +++ b/src/ServiceBusExplorer/ServiceBusExplorer.csproj @@ -24,7 +24,6 @@ false false true - true 8 Service Bus Explorer Paolo Salvatori @@ -550,7 +549,6 @@ - From e71d41c5d13ff98861b69baec54d58dae01e4e28 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Mon, 12 Aug 2024 13:25:14 +0100 Subject: [PATCH 11/25] add GenerateResourceUsePreserializedResources to allow dotnet build --- src/ServiceBusExplorer/ServiceBusExplorer.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ServiceBusExplorer/ServiceBusExplorer.csproj b/src/ServiceBusExplorer/ServiceBusExplorer.csproj index 2d937bfd..99943066 100644 --- a/src/ServiceBusExplorer/ServiceBusExplorer.csproj +++ b/src/ServiceBusExplorer/ServiceBusExplorer.csproj @@ -24,6 +24,7 @@ false false true + true 8 Service Bus Explorer Paolo Salvatori @@ -549,6 +550,7 @@ + From 6ddc8d814789c3323f4a7543ef23c4a4c80e7a32 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Tue, 13 Aug 2024 11:16:36 +0100 Subject: [PATCH 12/25] make setup private remove unused namespace --- .../Helpers/TwoFilesConfigurationTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs index e7562b44..e057e271 100644 --- a/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs +++ b/src/ServiceBusExplorer.Tests/Helpers/TwoFilesConfigurationTests.cs @@ -8,7 +8,6 @@ using ServiceBusExplorer.Helpers; using ServiceBusExplorer.Utilities.Helpers; using Microsoft.ServiceBus; -using System.Linq; using FluentAssertions; using Xunit; @@ -148,7 +147,7 @@ public TwoFilesConfigurationTests() #region Public methods //TODO: Refactor Setup - public void Setup() + private void Setup() { // Reset application config file. It does not work well just making a copy // of the application config file since it may have been modified by a previous From fe0d1e9ad72c2b1e64704f7b240a8bab01bddb69 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Tue, 13 Aug 2024 11:51:18 +0100 Subject: [PATCH 13/25] fix build versions on assembly --- src/Common/Properties/AssemblyInfo.cs | 33 ------------------- src/Directory.Build.props | 9 +++++ .../Properties/AssemblyInfo.cs | 33 ------------------- .../Properties/AssemblyInfo.cs | 32 ------------------ .../ServiceBusExplorer.Tests.csproj | 3 ++ src/ServiceBusExplorer.sln | 3 +- .../Properties/AssemblyInfo.cs | 3 -- 7 files changed, 14 insertions(+), 102 deletions(-) delete mode 100644 src/Common/Properties/AssemblyInfo.cs create mode 100644 src/Directory.Build.props delete mode 100644 src/NotificationHubs/Properties/AssemblyInfo.cs delete mode 100644 src/ServiceBusExplorer.Tests/Properties/AssemblyInfo.cs diff --git a/src/Common/Properties/AssemblyInfo.cs b/src/Common/Properties/AssemblyInfo.cs deleted file mode 100644 index f2c04b65..00000000 --- a/src/Common/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Common")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("de07dbeb-d772-49ba-bceb-a7ce29308ae3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.0.0.0")] diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..e7128671 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,9 @@ + + + false + false + false + false + false + + diff --git a/src/NotificationHubs/Properties/AssemblyInfo.cs b/src/NotificationHubs/Properties/AssemblyInfo.cs deleted file mode 100644 index 6f8af905..00000000 --- a/src/NotificationHubs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NotificationHubs")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NotificationHubs")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e836c914-9bfe-4c1c-96e5-6a414cdef485")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.0.0.0")] diff --git a/src/ServiceBusExplorer.Tests/Properties/AssemblyInfo.cs b/src/ServiceBusExplorer.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index aecc5a8b..00000000 --- a/src/ServiceBusExplorer.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ServiceBusExplorer.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("ServiceBusExplorer.Tests")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ab80c6e1-376c-4e98-8512-5ac9161e932b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.0.0.0")] diff --git a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj index cc4df90e..eb43b4da 100644 --- a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj +++ b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj @@ -35,4 +35,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/ServiceBusExplorer.sln b/src/ServiceBusExplorer.sln index 245e7ea3..7d308d20 100644 --- a/src/ServiceBusExplorer.sln +++ b/src/ServiceBusExplorer.sln @@ -8,8 +8,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B59933A5-4AE0-4340-9102-578619A93341}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - ..\LICENSE.txt = ..\LICENSE.txt + Directory.Build.props = Directory.Build.props EventGridExplorer_README.md = EventGridExplorer_README.md + ..\LICENSE.txt = ..\LICENSE.txt ..\README.md = ..\README.md EndProjectSection EndProject diff --git a/src/ServiceBusExplorer/Properties/AssemblyInfo.cs b/src/ServiceBusExplorer/Properties/AssemblyInfo.cs index 1410424b..bedf7f61 100644 --- a/src/ServiceBusExplorer/Properties/AssemblyInfo.cs +++ b/src/ServiceBusExplorer/Properties/AssemblyInfo.cs @@ -13,12 +13,9 @@ // associated with an assembly. [assembly: AssemblyTitle("Service Bus Explorer")] [assembly: AssemblyDescription("The Service Bus Explorer allows users to connect to a Service Bus namespace and easily administer and test the entities of an Azure Service Bus namespace. The tool provides advanced features like import/export functionality and the ability to test entities.")] -[assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Paolo Salvatori")] [assembly: AssemblyProduct("Service Bus Explorer")] [assembly: AssemblyCopyright("Copyright © Microsoft 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] // The following GUID is for the ID of the typelib if this project is exposed to COM From 063406c0a76b3ecad31fb97f7a2e3a5eaefcebe3 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Tue, 13 Aug 2024 12:00:23 +0100 Subject: [PATCH 14/25] Add input description --- .github/workflows/build-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e04ec5a2..893ab1fe 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -14,6 +14,7 @@ on: inputs: release-version: required: false + description: A version number to test manual builds. e.g. 2.1.1 type: string default: '0.0.0' env: From 518104a3b6ff1e7b063e74eac289c9f70f05fc21 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Tue, 13 Aug 2024 12:06:04 +0100 Subject: [PATCH 15/25] add missing build parameter --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 893ab1fe..cc523d7f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -49,7 +49,7 @@ jobs: - name: Build working-directory: ${{env.SOLUTION_FILE_PATH}} - run: dotnet build -c ${{env.BUILD_CONFIGURATION}} /p:AssemblyVersion=${{env.NUMBER_VERSION}} /p:InformationalVersion=${{inputs.release-version}} + run: dotnet build -c ${{env.BUILD_CONFIGURATION}} -p:GenerateAssemblyInfo=true,AssemblyVersion=${{env.NUMBER_VERSION}},InformationalVersion=${{inputs.release-version}} - name: Run tests working-directory: ${{env.SOLUTION_FILE_PATH}} From b2e2e7f44d115175cf69afa665b47d3133df9300 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh <79195459+asos-gurpreetsingh@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:56:31 +0100 Subject: [PATCH 16/25] Update src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj Co-authored-by: Sean Feldman --- src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj index eb43b4da..c69092ff 100644 --- a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj +++ b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj @@ -30,9 +30,7 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive + From b58e26acdd29735ab770199f769b2a8a2e6f5448 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh <79195459+asos-gurpreetsingh@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:58:43 +0100 Subject: [PATCH 17/25] Update src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj Co-authored-by: Sean Feldman --- src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj index c69092ff..d5820f79 100644 --- a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj +++ b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj @@ -33,7 +33,4 @@ - - - From 758412641f7ddea1c96f5c2c1f381ff097a32a80 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Sat, 21 Sep 2024 21:59:00 +0100 Subject: [PATCH 18/25] set file version and build version on assemblies --- .github/workflows/build-test.yml | 9 ++++- .../AssemblyVersionTests.cs | 39 +++++++++++++++++++ .../ServiceBusExplorer.csproj | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index cc523d7f..f2465304 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -49,9 +49,16 @@ jobs: - name: Build working-directory: ${{env.SOLUTION_FILE_PATH}} - run: dotnet build -c ${{env.BUILD_CONFIGURATION}} -p:GenerateAssemblyInfo=true,AssemblyVersion=${{env.NUMBER_VERSION}},InformationalVersion=${{inputs.release-version}} + run: >- + dotnet build -c ${{env.BUILD_CONFIGURATION}} + -p:GenerateAssemblyInfo=true + -p:AssemblyVersion=${{env.NUMBER_VERSION}} + -p:InformationalVersion=${{inputs.release-version}} + -p:FileVersion=${{inputs.release-version}} - name: Run tests + env: + FILE_VERSION: ${{inputs.release-version}} working-directory: ${{env.SOLUTION_FILE_PATH}} run: dotnet test -c ${{env.BUILD_CONFIGURATION}} diff --git a/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs b/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs new file mode 100644 index 00000000..c2f8f133 --- /dev/null +++ b/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs @@ -0,0 +1,39 @@ +using FluentAssertions; +using System; +using System.Diagnostics; +using System.Linq; +using Xunit; + +namespace ServiceBusExplorer.Tests +{ + public class AssemblyVersionTests + { + private string expectedVersion; + private string expectedFileVersion; + + public AssemblyVersionTests() + { +#if DEBUG + expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? "0.0.0.0"; + expectedFileVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? "0.0.0.0"; +#else + expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? throw new InvalidOperationException("Build number not set by environment"); + expectedFileVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? throw new InvalidOperationException("file version not set by environment"); +#endif + } + + [Fact] + public void AssemblyShouldHaveSameVersionAsProvidedByBuild() + { + typeof(Program).Assembly.GetName().Version.ToString().Should().Be(expectedVersion); + } + + [Fact] + public void FileShouldHaveSameVersionAsProvidedByBuild() + { + var fileVersion = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location); + + fileVersion.FileVersion.Should().Be(expectedFileVersion); + } + } +} diff --git a/src/ServiceBusExplorer/ServiceBusExplorer.csproj b/src/ServiceBusExplorer/ServiceBusExplorer.csproj index 99943066..87a0ee85 100644 --- a/src/ServiceBusExplorer/ServiceBusExplorer.csproj +++ b/src/ServiceBusExplorer/ServiceBusExplorer.csproj @@ -526,7 +526,7 @@ - PublicSettingsSingleFileGenerator + SettingsSingleFileGenerator Settings.Designer.cs From e069ffe2bd7b8c9e826b366b0ce0716c1a6b09fb Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Sat, 21 Sep 2024 22:10:24 +0100 Subject: [PATCH 19/25] file broken file after merge --- src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj index d5820f79..fb8c7d8e 100644 --- a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj +++ b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj @@ -31,6 +31,5 @@ - From 1b799c52cff1847112324787bb992a4108c49f69 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Sat, 21 Sep 2024 22:19:50 +0100 Subject: [PATCH 20/25] run tests with existing build output --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f2465304..0031b935 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -60,7 +60,7 @@ jobs: env: FILE_VERSION: ${{inputs.release-version}} working-directory: ${{env.SOLUTION_FILE_PATH}} - run: dotnet test -c ${{env.BUILD_CONFIGURATION}} + run: dotnet test -c ${{env.BUILD_CONFIGURATION}} --no-build --no-restore - name: Cache build uses: actions/cache@v3.0.11 From 1c323ba171bf26b588468cb305ce95794b5fc8e8 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Sat, 21 Sep 2024 22:54:57 +0100 Subject: [PATCH 21/25] fix version test set default value for release for testing manual builds --- .github/workflows/build-test.yml | 4 ++-- src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 0031b935..76bb1171 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -14,9 +14,9 @@ on: inputs: release-version: required: false - description: A version number to test manual builds. e.g. 2.1.1 + description: A version number to test manual builds. e.g. 1.2.3 type: string - default: '0.0.0' + default: '1.2.3' env: SOLUTION_FILE_PATH: .\src BUILD_CONFIGURATION: Release diff --git a/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs b/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs index c2f8f133..c25e2ebe 100644 --- a/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs +++ b/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs @@ -14,7 +14,7 @@ public class AssemblyVersionTests public AssemblyVersionTests() { #if DEBUG - expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? "0.0.0.0"; + expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? "0.0.0"; expectedFileVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? "0.0.0.0"; #else expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? throw new InvalidOperationException("Build number not set by environment"); @@ -25,6 +25,9 @@ public AssemblyVersionTests() [Fact] public void AssemblyShouldHaveSameVersionAsProvidedByBuild() { + var version=Version.Parse(expectedVersion); + if (version.Revision == -1) expectedVersion += ".0"; + typeof(Program).Assembly.GetName().Version.ToString().Should().Be(expectedVersion); } From bac86ff5e5ac0c42ece8e2109155344063cf8a13 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Sun, 22 Sep 2024 21:11:23 +0100 Subject: [PATCH 22/25] split tests to files with suitable names --- .../AssemblyVersionShould.cs | 30 +++++++++++++ .../AssemblyVersionTests.cs | 42 ------------------- .../FileVersionShould.cs | 30 +++++++++++++ 3 files changed, 60 insertions(+), 42 deletions(-) create mode 100644 src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs delete mode 100644 src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs create mode 100644 src/ServiceBusExplorer.Tests/FileVersionShould.cs diff --git a/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs b/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs new file mode 100644 index 00000000..ea47e530 --- /dev/null +++ b/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs @@ -0,0 +1,30 @@ +using FluentAssertions; +using System; +using System.Diagnostics; +using System.Linq; +using Xunit; + +namespace ServiceBusExplorer.Tests +{ + public class AssemblyVersionShould + { + private string expectedVersion; + + public AssemblyVersionShould() + { +#if DEBUG + expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? "0.0.0"; +#else + expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? throw new InvalidOperationException("Build number not set by environment"); +#endif + var version = Version.Parse(expectedVersion); + if (version.Revision == -1) expectedVersion += ".0"; + } + + [Fact] + public void BeSameAsProvidedByBuild() + { + typeof(Program).Assembly.GetName().Version.ToString().Should().Be(expectedVersion); + } + } +} diff --git a/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs b/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs deleted file mode 100644 index c25e2ebe..00000000 --- a/src/ServiceBusExplorer.Tests/AssemblyVersionTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -using FluentAssertions; -using System; -using System.Diagnostics; -using System.Linq; -using Xunit; - -namespace ServiceBusExplorer.Tests -{ - public class AssemblyVersionTests - { - private string expectedVersion; - private string expectedFileVersion; - - public AssemblyVersionTests() - { -#if DEBUG - expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? "0.0.0"; - expectedFileVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? "0.0.0.0"; -#else - expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? throw new InvalidOperationException("Build number not set by environment"); - expectedFileVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? throw new InvalidOperationException("file version not set by environment"); -#endif - } - - [Fact] - public void AssemblyShouldHaveSameVersionAsProvidedByBuild() - { - var version=Version.Parse(expectedVersion); - if (version.Revision == -1) expectedVersion += ".0"; - - typeof(Program).Assembly.GetName().Version.ToString().Should().Be(expectedVersion); - } - - [Fact] - public void FileShouldHaveSameVersionAsProvidedByBuild() - { - var fileVersion = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location); - - fileVersion.FileVersion.Should().Be(expectedFileVersion); - } - } -} diff --git a/src/ServiceBusExplorer.Tests/FileVersionShould.cs b/src/ServiceBusExplorer.Tests/FileVersionShould.cs new file mode 100644 index 00000000..0145db11 --- /dev/null +++ b/src/ServiceBusExplorer.Tests/FileVersionShould.cs @@ -0,0 +1,30 @@ +using FluentAssertions; +using System; +using System.Diagnostics; +using Xunit; + +namespace ServiceBusExplorer.Tests +{ + public class FileVersionShould + { + private string expectedVersion; + + public FileVersionShould() + { +#if DEBUG + expectedVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? "0.0.0.0"; +#else + expectedVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? throw new InvalidOperationException("file version not set by environment"); +#endif + } + + + [Fact] + public void FileShouldHaveSameVersionAsProvidedByBuild() + { + var fileVersion = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location); + + fileVersion.FileVersion.Should().Be(expectedVersion); + } + } +} From f51761a152db83dd6f0b65aced76cac9fcbc4907 Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Sun, 20 Oct 2024 21:57:15 +0100 Subject: [PATCH 23/25] separate assembly and file versions --- .github/workflows/build-test.yml | 11 - src/Common/Common.csproj | 2 +- src/Directory.Build.props | 1 + .../EventGridExplorerLibrary.csproj | 1 + src/EventHubs/EventHubs.csproj | 32 +- src/NotificationHubs/NotificationHubs.csproj | 80 +- src/Relay/Relay.csproj | 30 +- src/ServiceBus/ServiceBus.csproj | 27 +- .../AssemblyVersionShould.cs | 29 +- .../FileVersionShould.cs | 11 +- .../ServiceBusExplorer.Tests.csproj | 66 +- .../ServiceBusExplorer.csproj | 1333 ++++++++--------- src/Utilities/Utilities.csproj | 28 +- 13 files changed, 809 insertions(+), 842 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 76bb1171..71e0d355 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -38,21 +38,10 @@ jobs: - name: Show version run: echo "Building version ${{ inputs.release-version }}" - - name: Get number version - env: - ReleaseVersion: ${{ inputs.release-version }} - run: | - Write-Host "Using release version: $env:ReleaseVersion" - $numberVersion = .\GetNumberVersion -Version $env:ReleaseVersion - echo "Setting numberVersion to $numberVersion" - echo "NUMBER_VERSION=$numberVersion" >> $env:GITHUB_ENV - - name: Build working-directory: ${{env.SOLUTION_FILE_PATH}} run: >- dotnet build -c ${{env.BUILD_CONFIGURATION}} - -p:GenerateAssemblyInfo=true - -p:AssemblyVersion=${{env.NUMBER_VERSION}} -p:InformationalVersion=${{inputs.release-version}} -p:FileVersion=${{inputs.release-version}} diff --git a/src/Common/Common.csproj b/src/Common/Common.csproj index 63f84f53..1e16205a 100644 --- a/src/Common/Common.csproj +++ b/src/Common/Common.csproj @@ -6,7 +6,7 @@ net472 latest bin\$(Configuration)\ - false + 1.0.0.1 full diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e7128671..7fb3d384 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -5,5 +5,6 @@ false false false + true diff --git a/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj b/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj index a21d51ef..63db4004 100644 --- a/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj +++ b/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj @@ -3,6 +3,7 @@ Library netstandard2.0 + 1.0.0.1 diff --git a/src/EventHubs/EventHubs.csproj b/src/EventHubs/EventHubs.csproj index d9fef0cc..258851d5 100644 --- a/src/EventHubs/EventHubs.csproj +++ b/src/EventHubs/EventHubs.csproj @@ -1,22 +1,16 @@  - - - netstandard2.0 - 7.3 - ServiceBusExplorer.EventHubs - ServiceBusExplorer.EventHubs - - - - - - - - - - - - - + + netstandard2.0 + 7.3 + ServiceBusExplorer.EventHubs + ServiceBusExplorer.EventHubs + 1.0.0.1 + + + + + + + diff --git a/src/NotificationHubs/NotificationHubs.csproj b/src/NotificationHubs/NotificationHubs.csproj index 8baa1fd7..e2b3f63e 100644 --- a/src/NotificationHubs/NotificationHubs.csproj +++ b/src/NotificationHubs/NotificationHubs.csproj @@ -1,42 +1,42 @@  - - {E836C914-9BFE-4C1C-96E5-6A414CDEF485} - ServiceBusExplorer.NotificationHubs - ServiceBusExplorer.NotificationHubs - net472 - NotificationHubs - NotificationHubs - Copyright © 2019 - bin\$(Configuration)\ - false - - - full - - - pdbonly - - - - - - - - - - - - - - ExeInternalDependencyValidation.layerdiagram - False - - - AssemblyDependencyValidation.layerdiagram - False - - - - - + + {E836C914-9BFE-4C1C-96E5-6A414CDEF485} + ServiceBusExplorer.NotificationHubs + ServiceBusExplorer.NotificationHubs + 1.0.0.1 + net472 + NotificationHubs + NotificationHubs + Copyright © 2019 + bin\$(Configuration)\ + + + full + + + pdbonly + + + + + + + + + + + + + + ExeInternalDependencyValidation.layerdiagram + False + + + AssemblyDependencyValidation.layerdiagram + False + + + + + diff --git a/src/Relay/Relay.csproj b/src/Relay/Relay.csproj index 6be0eea2..89ac58de 100644 --- a/src/Relay/Relay.csproj +++ b/src/Relay/Relay.csproj @@ -1,20 +1,14 @@  - - - netstandard2.0 - 7.3 - ServiceBusExplorer.Relay - - - - - - - - - - - - - + + netstandard2.0 + 7.3 + ServiceBusExplorer.Relay + 1.0.0.1 + + + + + + + diff --git a/src/ServiceBus/ServiceBus.csproj b/src/ServiceBus/ServiceBus.csproj index d4e7ece4..a8f1bc8f 100644 --- a/src/ServiceBus/ServiceBus.csproj +++ b/src/ServiceBus/ServiceBus.csproj @@ -1,19 +1,14 @@  - - - netstandard2.0 - ServiceBusExplorer.ServiceBus - - - - - - - - - - - - + + netstandard2.0 + ServiceBusExplorer.ServiceBus + 1.0.0.1 + + + + + + + diff --git a/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs b/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs index ea47e530..4bdf1840 100644 --- a/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs +++ b/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs @@ -1,30 +1,25 @@ using FluentAssertions; -using System; -using System.Diagnostics; +using System.IO; using System.Linq; +using System.Reflection; using Xunit; namespace ServiceBusExplorer.Tests { public class AssemblyVersionShould { - private string expectedVersion; - - public AssemblyVersionShould() + [Fact] + public void BeSameAsSetInProject() { -#if DEBUG - expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? "0.0.0"; -#else - expectedVersion = Environment.GetEnvironmentVariable("NUMBER_VERSION") ?? throw new InvalidOperationException("Build number not set by environment"); -#endif - var version = Version.Parse(expectedVersion); - if (version.Revision == -1) expectedVersion += ".0"; - } + var expectedVersion = "1.0.0.1"; - [Fact] - public void BeSameAsProvidedByBuild() - { - typeof(Program).Assembly.GetName().Version.ToString().Should().Be(expectedVersion); + var assemblyNames = Directory.GetFiles(".", "ServiceBus*.*") + .Where(x=>x.EndsWith(".dll") || x.EndsWith(".exe")); + + var assemblyVersions = assemblyNames.Select(x=> + Assembly.LoadFrom(x).GetName().Version.ToString()); + + assemblyVersions.Should().HaveCount(8).And.AllBeEquivalentTo(expectedVersion); } } } diff --git a/src/ServiceBusExplorer.Tests/FileVersionShould.cs b/src/ServiceBusExplorer.Tests/FileVersionShould.cs index 0145db11..da7c7007 100644 --- a/src/ServiceBusExplorer.Tests/FileVersionShould.cs +++ b/src/ServiceBusExplorer.Tests/FileVersionShould.cs @@ -1,6 +1,8 @@ using FluentAssertions; using System; using System.Diagnostics; +using System.IO; +using System.Linq; using Xunit; namespace ServiceBusExplorer.Tests @@ -12,7 +14,7 @@ public class FileVersionShould public FileVersionShould() { #if DEBUG - expectedVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? "0.0.0.0"; + expectedVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? "1.0.0.1"; #else expectedVersion = Environment.GetEnvironmentVariable("FILE_VERSION") ?? throw new InvalidOperationException("file version not set by environment"); #endif @@ -22,9 +24,12 @@ public FileVersionShould() [Fact] public void FileShouldHaveSameVersionAsProvidedByBuild() { - var fileVersion = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location); + var assemblyNames = Directory.GetFiles(".", "ServiceBus*.*") + .Where(x => x.EndsWith(".dll") || x.EndsWith(".exe")); - fileVersion.FileVersion.Should().Be(expectedVersion); + var fileVersions = assemblyNames.Select(x => FileVersionInfo.GetVersionInfo(x).FileVersion); + + fileVersions.Should().HaveCount(8).And.AllBeEquivalentTo(expectedVersion); } } } diff --git a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj index fb8c7d8e..82762c36 100644 --- a/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj +++ b/src/ServiceBusExplorer.Tests/ServiceBusExplorer.Tests.csproj @@ -1,35 +1,35 @@  - - {41D3C27D-37FF-43B8-AAC0-4F483E507698} - net472 - latest - ServiceBusExplorer.Tests - Microsoft - ServiceBusExplorer.Tests - Copyright © Microsoft 2016 - bin\$(Configuration)\ - false - - - - - - - - - - - - - - - - - - - - - - - + + {41D3C27D-37FF-43B8-AAC0-4F483E507698} + net472 + latest + ServiceBusExplorer.Tests + 1.0.0.1 + Microsoft + ServiceBusExplorer.Tests + Copyright © Microsoft 2016 + bin\$(Configuration)\ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ServiceBusExplorer/ServiceBusExplorer.csproj b/src/ServiceBusExplorer/ServiceBusExplorer.csproj index 87a0ee85..8b3c4de0 100644 --- a/src/ServiceBusExplorer/ServiceBusExplorer.csproj +++ b/src/ServiceBusExplorer/ServiceBusExplorer.csproj @@ -1,669 +1,668 @@  - - - true - 8.0.30703 - {32754F39-E353-4607-94FE-B9B9ACFD58EF} - WinExe - net472 - false - true - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - true - 8 - Service Bus Explorer - Paolo Salvatori - Service Bus Explorer - The Service Bus Explorer allows users to connect to a Service Bus namespace and administer messaging entities in an easy manner. The tool provides advanced features like import/export functionality or the ability to test topic, queues, subscriptions, relay services, notification hubs and events hubs. - Copyright 2017 Paolo Salvatori - bin\$(Configuration)\ - false - false - Paolo Salvatori - - servicebusexplorer - - https://github.com/paolosalvatori/ServiceBusExplorer - https://github.com/paolosalvatori/ServiceBusExplorer/releases - servicebusexplorer azure azureservicebus servicebus explorer eventhub queue subscription relay notificationhub - - - AnyCPU - full - true - - - AnyCPU - pdbonly - - - NewServiceBusExplorerLogo.ico - - - - - - full - MinimumRecommendedRules.ruleset - - - pdbonly - MinimumRecommendedRules.ruleset - - - true - false - NewServiceBusExplorerLogo.jpg - https://github.com/paolosalvatori/ServiceBusExplorer - LICENSE.txt - app.manifest - - - - Libraries\FastColoredTextBox.dll - - - - - - - - - - - - - - - - - - - UserControl - - - AccidentalDeletionPreventionCheckControl.cs - - - Component - - - UserControl - - - HandleConsumerGroupControl.cs - - - UserControl - - - HandleEventHubControl.cs - - - UserControl - - - HandlePartitionControl.cs - - - UserControl - - - HandleRelayControl.cs - - - UserControl - - - PartitionListenerControl.cs - - - UserControl - - - ListenerControl.cs - - - UserControl - - - HandleNotificationHubControl.cs - - - UserControl - - - Component - - - Component - - - Component - - - Component - - - UserControl - - - TestEventHubControl.cs - - - UserControl - - - TimeSpanControl.cs - - - Component - - - UserControl - - - StandardValueEditorUI.cs - - - - TestRelayControl.cs - - - UserControl - - - TestSubscriptionControl.cs - - - - TestQueueControl.cs - - - UserControl - - - TestTopicControl.cs - - - UserControl - - - HandleRuleControl.cs - - - UserControl - - - HandleSubscriptionControl.cs - - - UserControl - - - HandleTopicControl.cs - - - Component - - - HeaderPanel.cs - - - UserControl - - - HandleQueueControl.cs - - - Form - - - ChangeQueueStatusForm.cs - - - Form - - - ConnectForm.cs - - - Form - - - ClipboardForm.cs - - - Form - - - ContainerForm.cs - - - Form - - - ChangeStatusForm.cs - - - Form - - - CollectionEditorForm.cs - - - Form - - - DateTimeRangeForm.cs - - - Form - - - EventDataForm.cs - - - Form - - - NewVersionAvailableForm.cs - - - Form - - - ParameterForm.cs - - - Form - - - RegistrationForm.cs - - - Form - - - UploadCertificateForm.cs - - - Form - - - MessageForm.cs - - - Form - - - ReceiveModeForm.cs - - - Form - - - DateTimeForm.cs - - - Form - - - FilterForm.cs - - - Form - - - RegistrationsForm.cs - - - Form - - - SelectEntityForm.cs - - - Form - - - TextForm.cs - - - Form - - - OptionForm.cs - - - Form - - - DeleteForm.cs - - - Form - - - AboutForm.cs - - - True - True - ServiceBusExplorerResources.resx - - - Form - - - MainForm.cs - - - AccidentalDeletionPreventionCheckControl.cs - - - HandleConsumerGroupControl.cs - Designer - - - HandleEventHubControl.cs - Designer - - - HandlePartitionControl.cs - - - HandleRelayControl.cs - Designer - - - PartitionListenerControl.cs - Designer - - - ListenerControl.cs - - - HandleNotificationHubControl.cs - - - Grouper.cs - Designer - - - TestEventHubControl.cs - - - TimeSpanControl.cs - - - Designer - - - StandardValueEditorUI.cs - - - TestRelayControl.cs - - - TestSubscriptionControl.cs - - - TestQueueControl.cs - - - TestTopicControl.cs - Designer - - - HandleRuleControl.cs - - - HandleSubscriptionControl.cs - - - HandleTopicControl.cs - Designer - - - HeaderPanel.cs - - - HandleQueueControl.cs - - - AboutForm.cs - - - ChangeQueueStatusForm.cs - - - ClipboardForm.cs - - - ContainerForm.cs - - - ChangeStatusForm.cs - - - CollectionEditorForm.cs - - - DateTimeRangeForm.cs - - - EventDataForm.cs - - - NewVersionAvailableForm.cs - - - ParameterForm.cs - - - RegistrationForm.cs - - - UploadCertificateForm.cs - - - MessageForm.cs - - - ReceiveModeForm.cs - - - DateTimeForm.cs - - - FilterForm.cs - - - RegistrationsForm.cs - - - SelectEntityForm.cs - - - TextForm.cs - - - OptionForm.cs - - - DeleteForm.cs - - - MainForm.cs - Designer - - - ConnectForm.cs - - - PublicResXFileCodeGenerator - Designer - Resources.Designer.cs - - - True - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - True - Resources.resx - - - True - Settings.settings - True - - - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + true + 8.0.30703 + {32754F39-E353-4607-94FE-B9B9ACFD58EF} + WinExe + net472 + true + 1.0.0.1 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + true + 8 + Service Bus Explorer + Paolo Salvatori + Service Bus Explorer + The Service Bus Explorer allows users to connect to a Service Bus namespace and administer messaging entities in an easy manner. The tool provides advanced features like import/export functionality or the ability to test topic, queues, subscriptions, relay services, notification hubs and events hubs. + Copyright 2017 Paolo Salvatori + bin\$(Configuration)\ + false + false + Paolo Salvatori + + servicebusexplorer + + https://github.com/paolosalvatori/ServiceBusExplorer + https://github.com/paolosalvatori/ServiceBusExplorer/releases + servicebusexplorer azure azureservicebus servicebus explorer eventhub queue subscription relay notificationhub + + + AnyCPU + full + true + + + AnyCPU + pdbonly + + + NewServiceBusExplorerLogo.ico + + + + + + full + MinimumRecommendedRules.ruleset + + + pdbonly + MinimumRecommendedRules.ruleset + + + true + false + NewServiceBusExplorerLogo.jpg + https://github.com/paolosalvatori/ServiceBusExplorer + LICENSE.txt + app.manifest + + + + Libraries\FastColoredTextBox.dll + + + + + + + + + + + + + + + + + + + UserControl + + + AccidentalDeletionPreventionCheckControl.cs + + + Component + + + UserControl + + + HandleConsumerGroupControl.cs + + + UserControl + + + HandleEventHubControl.cs + + + UserControl + + + HandlePartitionControl.cs + + + UserControl + + + HandleRelayControl.cs + + + UserControl + + + PartitionListenerControl.cs + + + UserControl + + + ListenerControl.cs + + + UserControl + + + HandleNotificationHubControl.cs + + + UserControl + + + Component + + + Component + + + Component + + + Component + + + UserControl + + + TestEventHubControl.cs + + + UserControl + + + TimeSpanControl.cs + + + Component + + + UserControl + + + StandardValueEditorUI.cs + + + + TestRelayControl.cs + + + UserControl + + + TestSubscriptionControl.cs + + + + TestQueueControl.cs + + + UserControl + + + TestTopicControl.cs + + + UserControl + + + HandleRuleControl.cs + + + UserControl + + + HandleSubscriptionControl.cs + + + UserControl + + + HandleTopicControl.cs + + + Component + + + HeaderPanel.cs + + + UserControl + + + HandleQueueControl.cs + + + Form + + + ChangeQueueStatusForm.cs + + + Form + + + ConnectForm.cs + + + Form + + + ClipboardForm.cs + + + Form + + + ContainerForm.cs + + + Form + + + ChangeStatusForm.cs + + + Form + + + CollectionEditorForm.cs + + + Form + + + DateTimeRangeForm.cs + + + Form + + + EventDataForm.cs + + + Form + + + NewVersionAvailableForm.cs + + + Form + + + ParameterForm.cs + + + Form + + + RegistrationForm.cs + + + Form + + + UploadCertificateForm.cs + + + Form + + + MessageForm.cs + + + Form + + + ReceiveModeForm.cs + + + Form + + + DateTimeForm.cs + + + Form + + + FilterForm.cs + + + Form + + + RegistrationsForm.cs + + + Form + + + SelectEntityForm.cs + + + Form + + + TextForm.cs + + + Form + + + OptionForm.cs + + + Form + + + DeleteForm.cs + + + Form + + + AboutForm.cs + + + True + True + ServiceBusExplorerResources.resx + + + Form + + + MainForm.cs + + + AccidentalDeletionPreventionCheckControl.cs + + + HandleConsumerGroupControl.cs + Designer + + + HandleEventHubControl.cs + Designer + + + HandlePartitionControl.cs + + + HandleRelayControl.cs + Designer + + + PartitionListenerControl.cs + Designer + + + ListenerControl.cs + + + HandleNotificationHubControl.cs + + + Grouper.cs + Designer + + + TestEventHubControl.cs + + + TimeSpanControl.cs + + + Designer + + + StandardValueEditorUI.cs + + + TestRelayControl.cs + + + TestSubscriptionControl.cs + + + TestQueueControl.cs + + + TestTopicControl.cs + Designer + + + HandleRuleControl.cs + + + HandleSubscriptionControl.cs + + + HandleTopicControl.cs + Designer + + + HeaderPanel.cs + + + HandleQueueControl.cs + + + AboutForm.cs + + + ChangeQueueStatusForm.cs + + + ClipboardForm.cs + + + ContainerForm.cs + + + ChangeStatusForm.cs + + + CollectionEditorForm.cs + + + DateTimeRangeForm.cs + + + EventDataForm.cs + + + NewVersionAvailableForm.cs + + + ParameterForm.cs + + + RegistrationForm.cs + + + UploadCertificateForm.cs + + + MessageForm.cs + + + ReceiveModeForm.cs + + + DateTimeForm.cs + + + FilterForm.cs + + + RegistrationsForm.cs + + + SelectEntityForm.cs + + + TextForm.cs + + + OptionForm.cs + + + DeleteForm.cs + + + MainForm.cs + Designer + + + ConnectForm.cs + + + PublicResXFileCodeGenerator + Designer + Resources.Designer.cs + + + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + True + Resources.resx + + + True + Settings.settings + True + + + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Utilities/Utilities.csproj b/src/Utilities/Utilities.csproj index 335a7164..2cc9f08a 100644 --- a/src/Utilities/Utilities.csproj +++ b/src/Utilities/Utilities.csproj @@ -1,19 +1,13 @@  - - - netstandard2.0 - ServiceBusExplorer.Utilities - 7.3 - ServiceBusExplorer.Utilities - ServiceBusExplorer.Utilities - - - - - - - - - - + + netstandard2.0 + ServiceBusExplorer.Utilities + 7.3 + ServiceBusExplorer.Utilities + 1.0.0.1 + ServiceBusExplorer.Utilities + + + + From e106b177cb82a472f94dd0a05e6132d7677bfc3b Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Sun, 20 Oct 2024 22:37:47 +0100 Subject: [PATCH 24/25] refactored unit tests to read expected versions from project files --- .../EventGridExplorerLibrary.csproj | 4 +++- .../AssemblyVersionShould.cs | 16 +++++++++++++--- .../FileVersionShould.cs | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj b/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj index 63db4004..d576b37b 100644 --- a/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj +++ b/src/EventGridExplorerLibrary/EventGridExplorerLibrary.csproj @@ -4,6 +4,8 @@ Library netstandard2.0 1.0.0.1 + EventGridExplorerLibrary + ServiceBusExplorer.EventGridExplorerLibrary @@ -16,7 +18,7 @@ - + diff --git a/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs b/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs index 4bdf1840..2f612870 100644 --- a/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs +++ b/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Xml; using Xunit; namespace ServiceBusExplorer.Tests @@ -11,15 +12,24 @@ public class AssemblyVersionShould [Fact] public void BeSameAsSetInProject() { - var expectedVersion = "1.0.0.1"; - var assemblyNames = Directory.GetFiles(".", "ServiceBus*.*") .Where(x=>x.EndsWith(".dll") || x.EndsWith(".exe")); + var projectFiles = Directory.GetFiles("../../../../", "*.csproj", SearchOption.AllDirectories); + + var xmlDocument = new XmlDocument(); + + var expectedVersions = projectFiles.Select(x => + { + xmlDocument.Load(x); + var nodes = xmlDocument.SelectSingleNode("//AssemblyVersion"); + return nodes.InnerText; + }).ToArray() ; + var assemblyVersions = assemblyNames.Select(x=> Assembly.LoadFrom(x).GetName().Version.ToString()); - assemblyVersions.Should().HaveCount(8).And.AllBeEquivalentTo(expectedVersion); + assemblyVersions.Should().HaveCount(9).And.BeEquivalentTo(expectedVersions); } } } diff --git a/src/ServiceBusExplorer.Tests/FileVersionShould.cs b/src/ServiceBusExplorer.Tests/FileVersionShould.cs index da7c7007..cc67be42 100644 --- a/src/ServiceBusExplorer.Tests/FileVersionShould.cs +++ b/src/ServiceBusExplorer.Tests/FileVersionShould.cs @@ -29,7 +29,7 @@ public void FileShouldHaveSameVersionAsProvidedByBuild() var fileVersions = assemblyNames.Select(x => FileVersionInfo.GetVersionInfo(x).FileVersion); - fileVersions.Should().HaveCount(8).And.AllBeEquivalentTo(expectedVersion); + fileVersions.Should().HaveCount(9).And.AllBeEquivalentTo(expectedVersion); } } } From 0318c4548bdbad45b0e11818620f3d3646fd2e5f Mon Sep 17 00:00:00 2001 From: asos-gurpreetsingh Date: Sun, 20 Oct 2024 22:53:08 +0100 Subject: [PATCH 25/25] check versions against assembly names --- .../AssemblyVersionShould.cs | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs b/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs index 2f612870..99e053ff 100644 --- a/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs +++ b/src/ServiceBusExplorer.Tests/AssemblyVersionShould.cs @@ -1,4 +1,5 @@ using FluentAssertions; +using System; using System.IO; using System.Linq; using System.Reflection; @@ -9,27 +10,47 @@ namespace ServiceBusExplorer.Tests { public class AssemblyVersionShould { + private const string CSharpProjectExtension = ".csproj"; + [Fact] public void BeSameAsSetInProject() { var assemblyNames = Directory.GetFiles(".", "ServiceBus*.*") .Where(x=>x.EndsWith(".dll") || x.EndsWith(".exe")); - var projectFiles = Directory.GetFiles("../../../../", "*.csproj", SearchOption.AllDirectories); + var projectFiles = Directory.GetFiles("../../../../", $"*{CSharpProjectExtension}", SearchOption.AllDirectories); var xmlDocument = new XmlDocument(); var expectedVersions = projectFiles.Select(x => { xmlDocument.Load(x); - var nodes = xmlDocument.SelectSingleNode("//AssemblyVersion"); - return nodes.InnerText; + var assemblyVersionNode = xmlDocument.SelectSingleNode("//AssemblyVersion"); + var assemblyNameNode = xmlDocument.SelectSingleNode("//AssemblyName"); + + return new + { + assemblyName = assemblyNameNode?.InnerText ?? ExtractProjectName(x), + assemblyVersion= assemblyVersionNode.InnerText + }; }).ToArray() ; - var assemblyVersions = assemblyNames.Select(x=> - Assembly.LoadFrom(x).GetName().Version.ToString()); + var actualAssemblyVersions = assemblyNames.Select(x=> + { + var assembly = Assembly.LoadFrom(x); + return new + { + assemblyName = assembly.GetName().Name, + assemblyVersion = assembly.GetName().Version.ToString() + }; + }).ToArray(); + + actualAssemblyVersions.Should().HaveCount(9).And.BeEquivalentTo(expectedVersions); + } - assemblyVersions.Should().HaveCount(9).And.BeEquivalentTo(expectedVersions); + private string ExtractProjectName(string x) + { + return new FileInfo(x).Name.Replace(CSharpProjectExtension, string.Empty); } } }