public void ShouldTransformFileWithDefaultLogger() { // Given var fixture = new XdtTransformationFixture { TargetFile = "/Working/transformed.config" }; // When var log = fixture.TransformConfigWithDefaultLogger(); // Then var transformedFile = fixture.FileSystem.GetFile(fixture.TargetFile); transformedFile.Exists.Should().BeTrue(); string transformedString; using (var transformedStream = transformedFile.OpenRead()) { using (var streamReader = new StreamReader(transformedStream, Encoding.UTF8)) { transformedString = streamReader.ReadToEnd(); } } transformedString.Should().Contain("<add key=\"transformed\" value=\"false\"/>"); transformedString.Should().NotContain("this-is-missing"); log.HasError.Should().BeFalse(); log.HasException.Should().BeFalse(); log.HasWarning.Should().BeTrue(); log.Log.Count.Should().Equals(15); }
public void ShouldErrorIfTargetFileIsNull() { // Given var fixture = new XdtTransformationFixture { TargetFile = null }; // When var result = Record.Exception(() => fixture.TransformConfig()); // Then result.Should().BeOfType <ArgumentNullException>().Subject.ParamName.Should().Equals("targetFile"); }
public void ShouldErrorIfTransformFileIsNull() { // Given var fixture = new XdtTransformationFixture { TransformFile = null }; // When var result = Record.Exception(() => fixture.TransformConfig()); // Then result.ShouldBeType <ArgumentNullException>().ParamName.ShouldEqual("transformFile"); }
public void ShouldErrorIfTransformFileNotExists() { // Given var fixture = new XdtTransformationFixture(transformFileExists: false) { TransformFile = "/Working/non-existing-transform.config" }; // When var result = Record.Exception(() => fixture.TransformConfig()); // Then result.Should().BeOfType <FileNotFoundException>().Subject.Message.Should().Contain("Unable to find the specified file."); }
public void ShouldTransformFile() { // Given var fixture = new XdtTransformationFixture { TargetFile = "/Working/transformed.config" }; // When fixture.TransformConfig(); // Then var transformedString = fixture.GetTargetFileContent(); transformedString.Should().Contain("<add key=\"transformed\" value=\"false\"/>"); }
public void ShouldTransformFileWithDefaultLoggerIfSameSourceAndTarget() { // Given var fixture = new XdtTransformationFixture(); fixture.TargetFile = fixture.SourceFile; // When fixture.TransformConfigWithDefaultLogger(); // Then var transformedString = fixture.GetTargetFileContent(); transformedString.Should().Contain("<add key=\"transformed\" value=\"false\"/>"); }
public void ShouldTransformFileWithDefaultLogger() { // Given var fixture = new XdtTransformationFixture { TargetFile = "/Working/transformed.config" }; // When var log = fixture.TransformConfigWithDefaultLogger(); // Then var transformedString = fixture.GetTargetFileContent(); transformedString.Should().Contain("<add key=\"transformed\" value=\"false\"/>"); transformedString.Should().NotContain("this-is-missing"); log.HasError.Should().BeFalse(); log.HasException.Should().BeFalse(); log.HasWarning.Should().BeTrue(); log.Log.Count.Should().Equals(15); }
public void ShouldTransformFile() { // Given var fixture = new XdtTransformationFixture { TargetFile = "/Working/transformed.config" }; // When fixture.TransformConfig(); // Then var transformedFile = fixture.FileSystem.GetFile(fixture.TargetFile); transformedFile.Exists.Should().BeTrue(); string transformedString; using (var transformedStream = transformedFile.OpenRead()) { using (var streamReader = new StreamReader(transformedStream, Encoding.UTF8)) { transformedString = streamReader.ReadToEnd(); } } transformedString.Should().Contain("<add key=\"transformed\" value=\"false\"/>"); }