public void DoesNothingIfThereAreNoMatchingVariables() { Replace(new CalamariVariables { { "Non-matching", "variable" } }, "appsettings.simple.json"); Log.MessagesInfoFormatted.Should().Contain(StructuredConfigMessages.NoStructuresFound); Log.MessagesVerboseFormatted.Should().NotContain(m => Regex.IsMatch(m, StructuredConfigMessages.StructureFound(".*"))); }
public void CanReplaceAnElementsText() { var vars = new CalamariVariables { { "/document/setting[@id='id-1']", "value<new" } }; RunTest(vars, "complex.xml"); Log.MessagesVerboseFormatted.Count(m => Regex.IsMatch(m, StructuredConfigMessages.StructureFound(".*"))).Should().Be(1); Log.MessagesVerboseFormatted.Should().Contain(StructuredConfigMessages.StructureFound("/document/setting[@id='id-1']")); Log.MessagesInfoFormatted.Should().NotContain(StructuredConfigMessages.NoStructuresFound); }
public void CanReplaceASimpleKeyValuePair() { var vars = new CalamariVariables { { "key1", "new-value" } }; RunTest(vars, "example.properties"); Log.MessagesVerboseFormatted.Count(m => Regex.IsMatch(m, StructuredConfigMessages.StructureFound(".*"))).Should().Be(1); Log.MessagesVerboseFormatted.Should().Contain(StructuredConfigMessages.StructureFound("key1")); Log.MessagesInfoFormatted.Should().NotContain(StructuredConfigMessages.NoStructuresFound); }
public void ShouldReplaceInSimpleFile() { this.Assent(Replace(new CalamariVariables { { "MyMessage", "Hello world" }, { "EmailSettings:SmtpHost", "localhost" }, { "EmailSettings:SmtpPort", "23" }, { "EmailSettings:DefaultRecipients:To", "*****@*****.**" }, { "EmailSettings:DefaultRecipients:Cc", "*****@*****.**" } }, "appsettings.simple.json"), TestEnvironment.AssentJsonConfiguration); Log.MessagesVerboseFormatted.Count(m => Regex.IsMatch(m, StructuredConfigMessages.StructureFound(".*"))).Should().Be(5); Log.MessagesVerboseFormatted.Should().Contain(StructuredConfigMessages.StructureFound("EmailSettings:SmtpPort")); Log.MessagesInfoFormatted.Should().NotContain(StructuredConfigMessages.NoStructuresFound); }
public void CanReplaceStringWithString() { this.Assent(Replace(new CalamariVariables { { "server:ports:0", "8080" }, { "spring:datasource:url", "" }, { "spring:h2:console:enabled", "false" }, { "spring:loggers:1:name", "rolling-file" }, { "environment", "production" } }, "application.yaml"), TestEnvironment.AssentYamlConfiguration); Log.MessagesVerboseFormatted.Count(m => Regex.IsMatch(m, StructuredConfigMessages.StructureFound(".*"))).Should().Be(5); Log.MessagesVerboseFormatted.Should().Contain(StructuredConfigMessages.StructureFound("spring:h2:console:enabled")); Log.MessagesInfoFormatted.Should().NotContain(StructuredConfigMessages.NoStructuresFound); }