示例#1
0
        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 });
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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 });
        }
示例#5
0
        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 });
        }