Beispiel #1
0
        public void DoesNotRemoveCommandsForTermsMatchingNewTermWhenTermChanges()
        {
            // Arrange
            const long term    = 2L;
            const long logIdx  = 3L;
            var        command = new TestCommand();

            var commandRegister = new CommandRegister();

            commandRegister.Add(term, logIdx, command);
            commandRegister.Get(term, logIdx).Should().Be(command);

            // Act
            commandRegister.Handle(new TermChanged(term));

            // Assert
            commandRegister.Get(term, logIdx).Should().Be(command);
        }
Beispiel #2
0
        public void RemovesCommandsForOlderTermsWhenTermChanges()
        {
            // Arrange
            const long term    = 1L;
            const long logIdx  = 3L;
            var        command = new TestCommand();

            var commandRegister = new CommandRegister();

            commandRegister.Add(term, logIdx, command);
            commandRegister.Get(term, logIdx).Should().Be(command);

            // Act
            commandRegister.Handle(new TermChanged(term + 1));

            // Assert
            commandRegister.Get(term, logIdx).Should().BeNull();
        }