Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailToPublishMismatchingStoredClusterId() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailToPublishMismatchingStoredClusterId()
        {
            // given
            ClusterId previouslyBoundClusterId = new ClusterId(System.Guid.randomUUID());

            CoreTopologyService topologyService = mock(typeof(CoreTopologyService));

            when(topologyService.SetClusterId(previouslyBoundClusterId, "default")).thenReturn(false);

            StubSimpleStorage <ClusterId> clusterIdStorage = new StubSimpleStorage <ClusterId>(this);

            clusterIdStorage.WriteState(previouslyBoundClusterId);

            ClusterBinder binder = ClusterBinder(clusterIdStorage, topologyService);

            // when
            try
            {
                binder.BindToCluster();
                fail("Should have thrown exception");
            }
            catch (BindingException)
            {
                // expected
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPublishStoredClusterIdIfPreviouslyBound() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPublishStoredClusterIdIfPreviouslyBound()
        {
            // given
            ClusterId previouslyBoundClusterId = new ClusterId(System.Guid.randomUUID());

            CoreTopologyService topologyService = mock(typeof(CoreTopologyService));

            when(topologyService.SetClusterId(previouslyBoundClusterId, "default")).thenReturn(true);

            StubSimpleStorage <ClusterId> clusterIdStorage = new StubSimpleStorage <ClusterId>(this);

            clusterIdStorage.WriteState(previouslyBoundClusterId);

            ClusterBinder binder = ClusterBinder(clusterIdStorage, topologyService);

            // when
            binder.BindToCluster();

            // then
            verify(topologyService).setClusterId(previouslyBoundClusterId, "default");
            Optional <ClusterId> clusterId = binder.Get();

            assertTrue(clusterId.Present);
            assertEquals(previouslyBoundClusterId, clusterId.get());
        }