예제 #1
0
        public void ShouldDeleteConflictAndSubsequentLogs()
        {
            var log = new InMemoryLog();

            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.DeleteConflictsFromThisLog(1, new LogEntry(new FakeCommand("test"), typeof(string), 2));
            log.ExposedForTesting.Count.ShouldBe(0);
        }
예제 #2
0
        public void ShouldDeleteConflictAndSubsequentLogsFromMidPoint()
        {
            var log = new InMemoryLog();

            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.DeleteConflictsFromThisLog(4, new LogEntry(new FakeCommand("test"), typeof(string), 2));
            log.ExposedForTesting.Count.ShouldBe(3);
            log.ExposedForTesting[1].Term.ShouldBe(1);
            log.ExposedForTesting[2].Term.ShouldBe(1);
            log.ExposedForTesting[3].Term.ShouldBe(1);
        }
예제 #3
0
        public async Task ShouldGetTermAtIndex()
        {
            var log = new InMemoryLog();
            await log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));

            log.GetTermAtIndex(1).Result.ShouldBe(1);
        }
예제 #4
0
        public async Task ShouldSetLastLogTerm()
        {
            var log = new InMemoryLog();
            await log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));

            log.LastLogTerm().Result.ShouldBe(1);
        }
예제 #5
0
        public async Task ShouldApplyLog()
        {
            var log   = new InMemoryLog();
            var index = await log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));

            index.ShouldBe(1);
        }
예제 #6
0
        public void ShouldGetTermAtIndex()
        {
            var log = new InMemoryLog();

            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.GetTermAtIndex(1).ShouldBe(1);
        }
예제 #7
0
        public void ShouldSetLastLogTerm()
        {
            var log = new InMemoryLog();

            log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));
            log.LastLogTerm.ShouldBe(1);
        }
예제 #8
0
        public void ShouldRemoveFromLog()
        {
            var log   = new InMemoryLog();
            var index = log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));

            log.Remove(index);
            log.Count.ShouldBe(0);
        }
예제 #9
0
        public async Task ShouldNotDeleteConflict()
        {
            var log = new InMemoryLog();
            await log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));

            await log.DeleteConflictsFromThisLog(1, new LogEntry(new FakeCommand("test"), typeof(string), 1));

            log.ExposedForTesting.Count.ShouldBe(1);
        }
예제 #10
0
        public async Task ShouldRemoveFromLog()
        {
            var log   = new InMemoryLog();
            var index = await log.Apply(new LogEntry(new FakeCommand("test"), typeof(string), 1));

            await log.Remove(index);

            log.Count().Result.ShouldBe(0);
        }
예제 #11
0
        public async Task ShouldBeDuplicate()
        {
            var log   = new InMemoryLog();
            var entry = new LogEntry(new FakeCommand("test"), typeof(string), 1);
            var index = await log.Apply(entry);

            var result = await log.IsDuplicate(index, entry);

            result.ShouldBeTrue();
        }