public void CanAddAlreadyExistingFileWontWriteChanges() { var writer = new ProjectFileWriter("test/test.csproj"); writer.AddNewCompile("asd/qwe/simsim.txt", "olá"); writer.WriteChanges(); using (new FileInfo(writer.ProjectPath).Open(FileMode.Open, FileAccess.ReadWrite)) { writer.AddNewCompile("asd/qwe/simsim.txt", "olá"); writer.WriteChanges(); } }
public void AddCompileFileToProjectThenRemoveItWontDeleteTheFile() { var writer = new ProjectFileWriter("test/test.csproj"); writer.AddNewCompile("asd/qwe/simsim.txt", "olá"); writer.WriteChanges(); writer.RemoveFile("asd/qwe/simsim.txt"); writer.WriteChanges(); StringAssert.DoesNotContain(@"<Compile Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test/test.csproj")); File.ReadAllText("test/asd/qwe/simsim.txt").Should().Be("olá"); }
public void CanAddCompileBinaryFileToProject() { var writer = new ProjectFileWriter("test/test.csproj"); writer.AddNewCompile("asd/qwe/simsim.txt", new byte[] { 1, 2, 3 }); writer.WriteChanges(); StringAssert.Contains(@"<Compile Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test/test.csproj")); File.ReadAllBytes("test/asd/qwe/simsim.txt").Should().Have.SameSequenceAs<byte>(1, 2, 3); }
public void CanCheckIfFileExists() { var writer = new ProjectFileWriter("test/test.csproj"); Assert.False(writer.ExistsFile("asd/qwe/simsim.txt")); writer.AddNewCompile("asd/qwe/simsim.txt", "olá"); Assert.True(writer.ExistsFile("asd/qwe/simsim.txt")); writer.WriteChanges(); }
public void CanAddCrazyFileToProject() { var writer = new ProjectFileWriter("test/test.csproj"); writer.AddNewFile("asd/qwe/simsim.txt", "ASDASD", "olá"); writer.WriteChanges(); StringAssert.Contains(@"<ASDASD Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test/test.csproj")); File.ReadAllText("test/asd/qwe/simsim.txt").Should().Be("olá"); }
public void CanAddCompileFileToProjectWorkEvenIfWeChangeDir() { var writer = new ProjectFileWriter("test/test.csproj"); Environment.CurrentDirectory = dir.ToString(); writer.AddNewCompile("asd/qwe/simsim.txt", "olá"); writer.WriteChanges(); StringAssert.Contains(@"<Compile Include=""asd\qwe\simsim.txt"" />", File.ReadAllText("test.csproj")); File.ReadAllText("asd/qwe/simsim.txt").Should().Be("olá"); }