private void TestLog(IPersistentLog <TestOperation> log) { var operations = new LogEntry <TestOperation>[] { new LogEntry <TestOperation>(new LogEntryId(1, 1), new TestOperation { StringValue = "operation1" }), new LogEntry <TestOperation>(new LogEntryId(1, 2), new TestOperation { StringValue = "operation2" }), new LogEntry <TestOperation>(new LogEntryId(1, 3), new TestOperation { StringValue = "operation3" }) }; log.AppendOrOverwrite(operations).Wait(); log.Contains(operations[0].Id).Should().BeTrue(); log.Contains(operations[1].Id).Should().BeTrue(); log.Contains(operations[2].Id).Should().BeTrue(); log.Contains(new LogEntryId(1, 4)).Should().BeFalse(); log.Contains(new LogEntryId(2, 1)).Should().BeFalse(); var entry2 = log.Get(2); entry2.Id.Should().Be(new LogEntryId(1, 2)); entry2.Operation.StringValue.Should().Be("operation2"); var entries = log.GetCursor(2).ToArray(); entries.Should().HaveCount(2); entries[0].Id.Should().Be(new LogEntryId(1, 2)); entries[1].Id.Should().Be(new LogEntryId(1, 3)); var reverseEntries = log.GetReverseCursor().ToArray(); reverseEntries.Should().HaveCount(3); reverseEntries[0].Id.Should().Be(new LogEntryId(1, 3)); reverseEntries[1].Id.Should().Be(new LogEntryId(1, 2)); reverseEntries[2].Id.Should().Be(new LogEntryId(1, 1)); }
void TestLog(IPersistentLog<TestOperation> log) { var operations = new LogEntry<TestOperation>[] { new LogEntry<TestOperation>(new LogEntryId(1, 1), new TestOperation { StringValue = "operation1" }), new LogEntry<TestOperation>(new LogEntryId(1, 2), new TestOperation { StringValue = "operation2" }), new LogEntry<TestOperation>(new LogEntryId(1, 3), new TestOperation { StringValue = "operation3" }) }; log.AppendOrOverwrite(operations).Wait(); log.Contains(operations[0].Id).Should().BeTrue(); log.Contains(operations[1].Id).Should().BeTrue(); log.Contains(operations[2].Id).Should().BeTrue(); log.Contains(new LogEntryId(1,4)).Should().BeFalse(); log.Contains(new LogEntryId(2, 1)).Should().BeFalse(); var entry2 = log.Get(2); entry2.Id.Should().Be(new LogEntryId(1, 2)); entry2.Operation.StringValue.Should().Be("operation2"); var entries = log.GetCursor(2).ToArray(); entries.Should().HaveCount(2); entries[0].Id.Should().Be(new LogEntryId(1, 2)); entries[1].Id.Should().Be(new LogEntryId(1, 3)); var reverseEntries = log.GetReverseCursor().ToArray(); reverseEntries.Should().HaveCount(3); reverseEntries[0].Id.Should().Be(new LogEntryId(1, 3)); reverseEntries[1].Id.Should().Be(new LogEntryId(1, 2)); reverseEntries[2].Id.Should().Be(new LogEntryId(1, 1)); }