Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateTokenId()
        public virtual void ShouldCreateTokenId()
        {
            // given
            TokenRegistry registry = new TokenRegistry("Label");
            ReplicatedTokenStateMachine stateMachine = new ReplicatedTokenStateMachine(registry, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            stateMachine.InstallCommitProcess(mock(typeof(TransactionCommitProcess)), -1);

            // when
            sbyte[] commandBytes = commandBytes(TokenCommands(_expectedTokenId));
            stateMachine.ApplyCommand(new ReplicatedTokenRequest(LABEL, "Person", commandBytes), 1, r =>
            {
            });

            // then
            assertEquals(_expectedTokenId, ( int )registry.GetId("Person"));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStoreRaftLogIndexInTransactionHeader()
        public virtual void ShouldStoreRaftLogIndexInTransactionHeader()
        {
            // given
            int logIndex = 1;

            StubTransactionCommitProcess commitProcess = new StubTransactionCommitProcess(null, null);
            ReplicatedTokenStateMachine  stateMachine  = new ReplicatedTokenStateMachine(new TokenRegistry("Token"), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            stateMachine.InstallCommitProcess(commitProcess, -1);

            // when
            sbyte[] commandBytes = commandBytes(TokenCommands(_expectedTokenId));
            stateMachine.ApplyCommand(new ReplicatedTokenRequest(LABEL, "Person", commandBytes), logIndex, r =>
            {
            });

            // then
            IList <TransactionRepresentation> transactions = commitProcess.TransactionsToApply;

            assertEquals(1, transactions.Count);
            assertEquals(logIndex, decodeLogIndexFromTxHeader(transactions[0].AdditionalHeader()));
        }