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 shouldRoundtripToChannel() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRoundtripToChannel()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IdAllocationState state = new IdAllocationState();
            IdAllocationState state = new IdAllocationState();

            for (int i = 1; i <= 3; i++)
            {
                state.FirstUnallocated(IdType.NODE, 1024 * i);
                state.LogIndex(i);
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IdAllocationState.Marshal marshal = new IdAllocationState.Marshal();
            IdAllocationState.Marshal marshal = new IdAllocationState.Marshal();
            // when
            InMemoryVersionableReadableClosablePositionAwareChannel channel = new InMemoryVersionableReadableClosablePositionAwareChannel();

            marshal.MarshalConflict(state, channel);
            IdAllocationState unmarshalled = marshal.unmarshal(channel);

            // then
            assertEquals(state, unmarshalled);
        }
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 shouldThrowExceptionForHalfWrittenEntries() throws java.io.IOException, org.neo4j.causalclustering.messaging.EndOfStreamException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionForHalfWrittenEntries()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IdAllocationState state = new IdAllocationState();
            IdAllocationState state = new IdAllocationState();

            for (int i = 1; i <= 3; i++)
            {
                state.FirstUnallocated(IdType.NODE, 1024 * i);
                state.LogIndex(i);
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IdAllocationState.Marshal marshal = new IdAllocationState.Marshal();
            IdAllocationState.Marshal marshal = new IdAllocationState.Marshal();
            // when
            InMemoryVersionableReadableClosablePositionAwareChannel channel = new InMemoryVersionableReadableClosablePositionAwareChannel();

            marshal.MarshalConflict(state, channel);
            // append some garbage
            channel.PutInt(1).putInt(2).putInt(3).putLong(4L);
            // read back in the first one
            marshal.unmarshal(channel);

            // the second one will be half read (the ints and longs appended above).
            try
            {
                marshal.unmarshal(channel);
                fail();
            }
            catch (EndOfStreamException)
            {
                // expected
            }
        }