private void When_creating_file_it_must_update_cache_on_refresh() { // Arrange const string path = @"c:\some\file.txt"; IFileSystem fileSystem = new FakeFileSystemBuilder() .IncludingDirectory(@"c:\some") .Build(); IFileInfo fileInfo = fileSystem.ConstructFileInfo(path); bool beforeFound = fileInfo.Exists; using (fileInfo.CreateText()) { } // Act fileInfo.Refresh(); // Assert bool afterFound = fileInfo.Exists; beforeFound.Should().BeFalse(); afterFound.Should().BeTrue(); }
private void When_creating_file_as_text_it_must_succeed() { // Arrange const string path = @"C:\some\file.txt"; IFileSystem fileSystem = new FakeFileSystemBuilder() .IncludingDirectory(@"c:\some") .Build(); IFileInfo info = fileSystem.ConstructFileInfo(path); // Act using (StreamWriter writer = info.CreateText()) { // Assert writer.BaseStream.CanRead.Should().BeFalse(); writer.BaseStream.CanWrite.Should().BeTrue(); } }
private void When_creating_file_it_must_succeed() { // Arrange const string path = @"c:\some\file.txt"; IFileSystem fileSystem = new FakeFileSystemBuilder() .IncludingDirectory(@"c:\some") .Build(); IFileInfo fileInfo = fileSystem.ConstructFileInfo(path); // Act using (fileInfo.CreateText()) { } // Assert fileSystem.File.Exists(path).Should().BeTrue(); fileSystem.File.ReadAllText(path).Should().Be(string.Empty); }
public void Execute(InstrumentationResult result, IFileInfo output) { var hits = HitsInfo.TryReadFromDirectory(result.HitsPath); var document = new XDocument( new XDeclaration("1.0", "utf-8", null), CreateCoverageElement(result, hits) ); var xmlWriterSettings = new XmlWriterSettings { Indent = true }; output.Directory.Create(); using (var sw = output.CreateText()) using (var writer = XmlWriter.Create(sw, xmlWriterSettings)) { document.WriteTo(writer); } }
public void Execute(InstrumentationResult result, IFileInfo output) { var hits = _hitsReader.TryReadFromDirectory(result.HitsPath); var document = new XDocument( new XDeclaration("1.0", "utf-8", null), new XDocumentType("coverage", null, "http://cobertura.sourceforge.net/xml/coverage-04.dtd", null), CreateCoverageElement(result, hits) ); var xmlWriterSettings = new XmlWriterSettings { Indent = true }; output.Directory.Create(); using (var sw = output.CreateText()) using (var writer = XmlWriter.Create(sw, xmlWriterSettings)) { document.WriteTo(writer); } }
private void When_changing_file_length_it_must_not_refresh_automatically() { // Arrange const string path = @"c:\some\file.txt"; IFileSystem fileSystem = new FakeFileSystemBuilder() .IncludingTextFile(path, DefaultContents) .Build(); IFileInfo fileInfo = fileSystem.ConstructFileInfo(path); long beforeLength = fileInfo.Length; // Act using (fileInfo.CreateText()) { } // Assert long afterLength = fileInfo.Length; beforeLength.Should().Be(DefaultContents.Length); afterLength.Should().Be(DefaultContents.Length); }