Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void filtersSelf() throws org.neo4j.causalclustering.upstream.UpstreamDatabaseSelectionException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FiltersSelf()
        {
            // given
            MemberId myself    = new MemberId(new System.Guid(1234, 5678));
            Config   config    = Config.defaults();
            string   groupName = "groupName";

            // and
            ConnectToRandomCoreServerStrategy connectToRandomCoreServerStrategy = new ConnectToRandomCoreServerStrategy();

            connectToRandomCoreServerStrategy.Inject(new TopologyServiceThatPrioritisesItself(myself, groupName), config, NullLogProvider.Instance, myself);

            // when
            Optional <MemberId> found = connectToRandomCoreServerStrategy.UpstreamDatabase();

            // then
            Assert.assertTrue(found.Present);
            Assert.assertNotEquals(myself, found);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConnectToRandomCoreServer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldConnectToRandomCoreServer()
        {
            // given
            MemberId memberId1 = new MemberId(System.Guid.randomUUID());
            MemberId memberId2 = new MemberId(System.Guid.randomUUID());
            MemberId memberId3 = new MemberId(System.Guid.randomUUID());

            TopologyService topologyService = mock(typeof(TopologyService));

            when(topologyService.LocalCoreServers()).thenReturn(FakeCoreTopology(memberId1, memberId2, memberId3));

            ConnectToRandomCoreServerStrategy connectionStrategy = new ConnectToRandomCoreServerStrategy();

            connectionStrategy.Inject(topologyService, Config.defaults(), NullLogProvider.Instance, null);

            // when
            Optional <MemberId> memberId = connectionStrategy.UpstreamDatabase();

            // then
            assertTrue(memberId.Present);
            assertThat(memberId.get(), anyOf(equalTo(memberId1), equalTo(memberId2), equalTo(memberId3)));
        }