Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSetDiscoveryHeaderProperly() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSetDiscoveryHeaderProperly()
        {
            // GIVEN
            ClusterContext context = mock(typeof(ClusterContext));

            when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance);
            when(context.GetUriForId(Id(2))).thenReturn(Uri(2));
            when(context.JoiningInstances).thenReturn(singletonList(Uri(2)));

            IList <ConfigurationRequestState> discoveredInstances = new LinkedList <ConfigurationRequestState>();

            when(context.DiscoveredInstances).thenReturn(discoveredInstances);

            TrackingMessageHolder outgoing = new TrackingMessageHolder();

            ClusterMessage.ConfigurationTimeoutState timeoutState = new ClusterMessage.ConfigurationTimeoutState(3);
            Message <ClusterMessage> message = @internal(configurationTimeout, timeoutState);
            string discoveryHeader           = "1,2,3";

            when(context.GenerateDiscoveryHeader()).thenReturn(discoveryHeader);

            // WHEN
            // We receive a configuration request from an instance which we haven't contacted
            ClusterState.Discovery.handle(context, message, outgoing);

            // THEN
            // It shouldn't be added to the discovered instances
            assertEquals(discoveryHeader, outgoing.First().getHeader(DISCOVERED));
        }