Beispiel #1
0
        public void SetValueAndFlushWritesEntryToDisk()
        {
            FileBasedDictionaryFileSystem        fs  = new FileBasedDictionaryFileSystem();
            FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty);

            dut.SetValueAndFlush(TestKey, TestValue);

            fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(TestEntry);
        }
Beispiel #2
0
        public void SetValueAndFlushWritesEntryToDisk()
        {
            FileBasedDictionaryFileSystem        fs  = new FileBasedDictionaryFileSystem();
            FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty);

            dut.SetValueAndFlush(TestKey, TestValue);

            this.FileBasedDictionaryFileSystemShouldContain(fs, new[] { TestEntry });
        }
Beispiel #3
0
        public void SetValueAndFlushUpdatedEntryOnDisk()
        {
            FileBasedDictionaryFileSystem        fs  = new FileBasedDictionaryFileSystem();
            FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, TestEntry);

            dut.SetValueAndFlush(TestKey, UpdatedTestValue);

            this.FileBasedDictionaryFileSystemShouldContain(fs, new[] { UpdatedTestEntry });
        }
Beispiel #4
0
        public void SetValueAndFlushRecoversFromMixOfFailures()
        {
            FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(failuresAcrossOpenExistsAndOverwritePath: MockEntryFileName + ".tmp");

            FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty);

            dut.SetValueAndFlush(TestKey, TestValue);

            fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(TestEntry);
        }
Beispiel #5
0
        public void SetValueAndFlushRecoversFromMixOfFailures()
        {
            FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(failuresAcrossOpenExistsAndOverwritePath: MockEntryFileName + ".tmp");

            FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty);

            dut.SetValueAndFlush(TestKey, TestValue);

            this.FileBasedDictionaryFileSystemShouldContain(fs, new[] { TestEntry });
        }
Beispiel #6
0
        public void SetValueAndFlushRecoversFromDeletedTempAndFailedOverwrite()
        {
            FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(
                openFileStreamFailurePath: null,
                maxOpenFileStreamFailures: 0,
                fileExistsFailurePath: MockEntryFileName + ".tmp",
                maxFileExistsFailures: 5,
                maxMoveAndOverwriteFileFailures: 5);

            FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty);

            dut.SetValueAndFlush(TestKey, TestValue);

            fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(TestEntry);
        }
Beispiel #7
0
        public void SetValueAndFlushRecoversFromDeletedTempAndFailedOverwrite()
        {
            FileBasedDictionaryFileSystem fs = new FileBasedDictionaryFileSystem(
                openFileStreamFailurePath: null,
                maxOpenFileStreamFailures: 0,
                fileExistsFailurePath: MockEntryFileName + ".tmp",
                maxFileExistsFailures: 5,
                maxMoveAndOverwriteFileFailures: 5);

            FileBasedDictionary <string, string> dut = CreateFileBasedDictionary(fs, string.Empty);

            dut.SetValueAndFlush(TestKey, TestValue);

            this.FileBasedDictionaryFileSystemShouldContain(fs, new[] { TestEntry });
        }
Beispiel #8
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 });
        }