public void OpenNonExistantKeyForWriteWithCreateCreatesNewData() { // Arrange InMemoryFileSystem fs = new InMemoryFileSystem(); GitLooseFilesDictionary db = new GitLooseFilesDictionary(fs, new NullCompressionStrategy()); // Assume Assert.False(fs.Exists(@"ab\cdefghijk")); // Act using (Stream strm = db.OpenWrite("abcdefghijk", create: true)) using (StreamWriter writer = new StreamWriter(strm)) { writer.Write("FooBarBaz"); } // Assert Assert.Equal("FooBarBaz", fs.ReadTestFile(@"ab\cdefghijk")); }
public void OpenExistingKeyForWriteAndEditData() { // Arrange InMemoryFileSystem fs = new InMemoryFileSystem(); GitLooseFilesDictionary db = new GitLooseFilesDictionary(fs, new NullCompressionStrategy()); fs.WriteTestFile(@"ab\cdefghijk", "Foo"); // Act using (Stream strm = db.OpenWrite("abcdefghijk", create: false)) using (StreamWriter writer = new StreamWriter(strm)) { strm.Seek(2, SeekOrigin.Begin); writer.Write("Bar"); } // Assert Assert.Equal("FoBar", fs.ReadTestFile(@"ab\cdefghijk")); }
public void OpenNonExistantKeyForWriteWithCreateCreatesNewData() { // Arrange InMemoryFileSystem fs = new InMemoryFileSystem(); GitLooseFilesDictionary db = new GitLooseFilesDictionary(fs, new NullCompressionStrategy()); // Assume Assert.False(fs.Exists(@"ab\cdefghijk")); // Act using (Stream strm = db.OpenWrite("abcdefghijk", create: true)) using(StreamWriter writer = new StreamWriter(strm)) { writer.Write("FooBarBaz"); } // Assert Assert.Equal("FooBarBaz", fs.ReadTestFile(@"ab\cdefghijk")); }