//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPersistAndRecoverState() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPersistAndRecoverState() { // given EphemeralFileSystemAbstraction fsa = FileSystemRule.get(); fsa.Mkdir(TestDir.directory()); StateMarshal <ReplicatedLockTokenState> marshal = new ReplicatedLockTokenState.Marshal(new MemberId.Marshal()); MemberId memberA = member(0); MemberId memberB = member(1); int candidateId; DurableStateStorage <ReplicatedLockTokenState> storage = new DurableStateStorage <ReplicatedLockTokenState>(fsa, TestDir.directory(), "state", marshal, 100, NullLogProvider.Instance); using (Lifespan lifespan = new Lifespan(storage)) { ReplicatedLockTokenStateMachine stateMachine = new ReplicatedLockTokenStateMachine(storage); // when candidateId = 0; stateMachine.ApplyCommand(new ReplicatedLockTokenRequest(memberA, candidateId), 0, r => { }); candidateId = 1; stateMachine.ApplyCommand(new ReplicatedLockTokenRequest(memberB, candidateId), 1, r => { }); stateMachine.Flush(); fsa.Crash(); } // then DurableStateStorage <ReplicatedLockTokenState> storage2 = new DurableStateStorage <ReplicatedLockTokenState>(fsa, TestDir.directory(), "state", marshal, 100, NullLogProvider.Instance); using (Lifespan lifespan = new Lifespan(storage2)) { ReplicatedLockTokenState initialState = storage2.InitialState; assertEquals(memberB, initialState.Get().owner()); assertEquals(candidateId, initialState.Get().id()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSetInitialPendingRequestToInitialState() public virtual void ShouldSetInitialPendingRequestToInitialState() { // Given //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.causalclustering.core.state.storage.StateStorage<ReplicatedLockTokenState> storage = mock(org.neo4j.causalclustering.core.state.storage.StateStorage.class); StateStorage <ReplicatedLockTokenState> storage = mock(typeof(StateStorage)); MemberId initialHoldingCoreMember = member(0); ReplicatedLockTokenState initialState = new ReplicatedLockTokenState(123, new ReplicatedLockTokenRequest(initialHoldingCoreMember, 3)); when(storage.InitialState).thenReturn(initialState); // When ReplicatedLockTokenStateMachine stateMachine = new ReplicatedLockTokenStateMachine(storage); // Then LockToken initialToken = stateMachine.CurrentToken(); assertEquals(initialState.Get().owner(), initialToken.Owner()); assertEquals(initialState.Get().id(), initialToken.Id()); }