public void FindAllResourceTemplatesWithMessageBusOnly(AzureIntegrationServicesModel model, IEnumerable <TargetResourceTemplate> resources, Exception e) { "Given a model" .x(() => model = _model); "And the model only has resources for the message bus" .x(() => { _model.MigrationTarget.MessageBus.Applications.SelectMany(a => a.Channels).ToList().ForEach(a => a.Resources.Clear()); _model.MigrationTarget.MessageBus.Applications.SelectMany(a => a.Endpoints).ToList().ForEach(a => a.Resources.Clear()); _model.MigrationTarget.MessageBus.Applications.SelectMany(a => a.Messages).ToList().ForEach(a => a.Resources.Clear()); _model.MigrationTarget.MessageBus.Applications.SelectMany(a => a.Intermediaries).ToList().ForEach(a => a.Resources.Clear()); }); "When finding all resource templates" .x(() => e = Record.Exception(() => resources = CustomLiquidFunctions.FindAllResourceTemplates(model))); "Then the find should succeed" .x(() => e.Should().BeNull()); "And the target resource should be the expected value from the model" .x(() => { resources.Should().NotBeNullOrEmpty(); resources.Should().HaveCount(1); }); }
public void ToSafeFilePathWithSuccess(string filePath, string safeFilePath, Exception e) { "Given a file path" .x(() => filePath = "this//is\\\\a\\\\t?e>st/to/s e|e*/if/:th\"e/path/i<s/conver>ted"); "When making the filepath safe" .x(() => e = Record.Exception(() => safeFilePath = CustomLiquidFunctions.ToSafeFilePath(filePath))); "Then the conversion should succeed" .x(() => e.Should().BeNull()); "And the safe file path should be converted" .x(() => safeFilePath.Should().Be("this/is/a/test/to/see/if/the/path/is/converted")); }
public void ToNullSafeFilePathWithSuccess(string filePath, string safeFilePath, Exception e) { "Given a null file path" .x(() => filePath = null); "When making the file path safe" .x(() => e = Record.Exception(() => safeFilePath = CustomLiquidFunctions.ToSafeFilePath(filePath))); "Then the conversion should succeed" .x(() => e.Should().BeNull()); "And the safe file path should be null" .x(() => safeFilePath.Should().BeNull()); }
public void ToNullJsonStringWithSuccess(string value, string jsonString, Exception e) { "Given a null string" .x(() => value = null); "When converting the string" .x(() => e = Record.Exception(() => jsonString = CustomLiquidFunctions.ToJsonString(value))); "Then the conversion should succeed" .x(() => e.Should().BeNull()); "And the JSON string should be null" .x(() => jsonString.Should().BeNull()); }
public void ToEscapedJsonStringWithSuccess(string value, string jsonString, Exception e) { "Given a string" .x(() => value = "\"Quoted String with Backslash \\ Character\""); "When converting the string" .x(() => e = Record.Exception(() => jsonString = CustomLiquidFunctions.ToJsonString(value))); "Then the conversion should succeed" .x(() => e.Should().BeNull()); "And the JSON string should have the expected value" .x(() => jsonString.Should().Be("\\\"Quoted String with Backslash \\\\ Character\\\"")); }
public void FormatRegionWithRegionNullError(string region, string formattedRegion, Exception e) { "Given a null region" .x(() => region.Should().BeNull()); "When formatting the region" .x(() => e = Record.Exception(() => formattedRegion = CustomLiquidFunctions.FormatRegion(region))); "Then the format should succeed" .x(() => e.Should().BeNull()); "And the formatted region should be null" .x(() => formattedRegion.Should().BeNull()); }
public void FormatMissingRegionWithSuccess(string region, string formattedRegion, Exception e) { "Given a region" .x(() => region = "Non-Existent Region"); "When formatting the region" .x(() => e = Record.Exception(() => formattedRegion = CustomLiquidFunctions.FormatRegion(region))); "Then the format should succeed" .x(() => e.Should().BeNull()); "And the formatted region should be null" .x(() => formattedRegion.Should().BeNull()); }
public void FormatRegionWithSuccess(string region, string formattedRegion, Exception e) { "Given a region" .x(() => region = "UK South"); "When formatting the region" .x(() => e = Record.Exception(() => formattedRegion = CustomLiquidFunctions.FormatRegion(region))); "Then the format should succeed" .x(() => e.Should().BeNull()); "And the formatted region should have the expected value" .x(() => formattedRegion.Should().Be("uksouth")); }
public void FindChannelMissingResourceWithSuccess(AzureIntegrationServicesModel model, string templateKey, TargetResourceTemplate resource, Exception e) { "Given a model" .x(() => model = _model); "And a template key for a resource that doesn't exist" .x(() => templateKey = "missingChannel"); "When finding the resource template" .x(() => e = Record.Exception(() => resource = CustomLiquidFunctions.FindResourceTemplate(model, templateKey))); "Then the find should succeed" .x(() => e.Should().BeNull()); "And the target resource should be null" .x(() => resource.Should().BeNull()); }
public void FindAllResourceTemplatesWithNullModel(AzureIntegrationServicesModel model, IEnumerable <TargetResourceTemplate> resources, Exception e) { "Given a null model" .x(() => model = null); "When finding all resource templates" .x(() => e = Record.Exception(() => resources = CustomLiquidFunctions.FindAllResourceTemplates(model))); "Then the find should succeed" .x(() => e.Should().BeNull()); "And the target resource should be the expected value from the model" .x(() => { resources.Should().BeNull(); }); }
public void FindChannelResourceWithTemplateKeyNullError(AzureIntegrationServicesModel model, string templateKey, TargetResourceTemplate resource, Exception e) { "Given a model" .x(() => model = _model); "And a null template key" .x(() => templateKey.Should().BeNull()); "When finding the resource template" .x(() => e = Record.Exception(() => resource = CustomLiquidFunctions.FindResourceTemplate(model, templateKey))); "Then the find should succeed" .x(() => e.Should().BeNull()); "And the target resource should be null" .x(() => resource.Should().BeNull()); }
public void GetEnvironmentVariableWithEnvVarNameNullError(string name, string env, Exception e) { "Given a null name" .x(() => name.Should().BeNull()); "And a test environment variable" .x(() => Environment.SetEnvironmentVariable("TESTENV", "This Is A Test")) .Teardown(() => Environment.SetEnvironmentVariable("TESTENV", null)); "When getting the environment variable" .x(() => e = Record.Exception(() => env = CustomLiquidFunctions.GetEnvironmentVariable(name))); "Then the get should succeed" .x(() => e.Should().BeNull()); "And the environment variable should be null" .x(() => env.Should().BeNull()); }
public void GetEnvironmentVariableWithSuccess(string name, string env, Exception e) { "Given a name" .x(() => name = "TESTENV"); "And a test environment variable" .x(() => Environment.SetEnvironmentVariable(name, "This Is A Test")) .Teardown(() => Environment.SetEnvironmentVariable(name, null)); "When getting the environment variable" .x(() => e = Record.Exception(() => env = CustomLiquidFunctions.GetEnvironmentVariable(name))); "Then the get should succeed" .x(() => e.Should().BeNull()); "And the environment variable should have the expected value" .x(() => env.Should().Be("This Is A Test")); }
public void FindChannelResourceWithSuccess(AzureIntegrationServicesModel model, string templateKey, TargetResourceTemplate resource, Exception e) { "Given a model" .x(() => model = _model); "And a template key" .x(() => templateKey = "topicChannelAzureServiceBusStandard"); "When finding the resource template" .x(() => e = Record.Exception(() => resource = CustomLiquidFunctions.FindResourceTemplate(model, templateKey))); "Then the find should succeed" .x(() => e.Should().BeNull()); "And the target resource should be the expected value from the model" .x(() => { resource.Should().NotBeNull(); resource.TemplateKey.Should().Be("topicChannelAzureServiceBusStandard"); }); }