public void SetValuesAndFlushWritesUpdatesExistingEntriesOnDisk() { FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(); FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty); dut.SetValuesAndFlush( new[] { new KeyValuePair <string, string>(TestKey, TestValue), new KeyValuePair <string, string>(TestKey2, TestValue2), }); this.FileBasedDictionaryFileSystemShouldContain(fs, new[] { TestEntry, TestEntry2 }); dut.SetValuesAndFlush( new[] { new KeyValuePair <string, string>(TestKey, UpdatedTestValue), new KeyValuePair <string, string>(TestKey2, UpdatedTestValue2), }); this.FileBasedDictionaryFileSystemShouldContain(fs, new[] { UpdatedTestEntry, UpdatedTestEntry2 }); }
public void SetValuesAndFlushWritesUpdatesExistingEntriesOnDisk() { FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(); FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty); dut.SetValuesAndFlush( new[] { new KeyValuePair <string, string>(TestKey, TestValue), new KeyValuePair <string, string>(TestKey2, TestValue2), }); fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(TestEntry + TestEntry2); dut.SetValuesAndFlush( new[] { new KeyValuePair <string, string>(TestKey, UpdatedTestValue), new KeyValuePair <string, string>(TestKey2, UpdatedTestValue2), }); fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(UpdatedTestEntry + UpdatedTestEntry2); }
public void SetValuesAndFlushUsesLastValueWhenKeyDuplicated() { FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(); FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty); dut.SetValuesAndFlush( new[] { new KeyValuePair <string, string>(TestKey, TestValue), new KeyValuePair <string, string>(TestKey, UpdatedTestValue), }); fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(UpdatedTestEntry); }
public void SetValuesAndFlushUsesLastValueWhenKeyDuplicated() { FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(); FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty); dut.SetValuesAndFlush( new[] { new KeyValuePair <string, string>(TestKey, TestValue), new KeyValuePair <string, string>(TestKey, UpdatedTestValue), }); this.FileBasedDictionaryFileSystemShouldContain(fs, new[] { UpdatedTestEntry }); }
public void SetValuesAndFlushWritesNewEntryAndUpdatesExistingEntryOnDisk() { FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(); FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty); // Add TestKey to disk dut.SetValueAndFlush(TestKey, TestValue); fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(TestEntry); // This call to SetValuesAndFlush should update TestKey and write TestKey2 dut.SetValuesAndFlush( new[] { new KeyValuePair <string, string>(TestKey, UpdatedTestValue), new KeyValuePair <string, string>(TestKey2, TestValue2), }); this.FileBasedDictionaryFileSystemShouldContain(fs, new[] { UpdatedTestEntry, TestEntry2 }); }