//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void discoveredInstancesShouldBeOnlyOnesWeHaveContactedDirectly() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DiscoveredInstancesShouldBeOnlyOnesWeHaveContactedDirectly() { // GIVEN ClusterContext context = mock(typeof(ClusterContext)); when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance); when(context.GetUriForId(Id(2))).thenReturn(Uri(2)); IList <ConfigurationRequestState> discoveredInstances = new LinkedList <ConfigurationRequestState>(); when(context.DiscoveredInstances).thenReturn(discoveredInstances); when(context.ShouldFilterContactingInstances()).thenReturn(true); MessageHolder outgoing = mock(typeof(MessageHolder)); ConfigurationRequestState configurationRequestFromTwo = Configuration(2); Message <ClusterMessage> message = to(configurationRequest, Uri(1), configurationRequestFromTwo).setHeader(Message.HEADER_FROM, Uri(2).ToString()); // 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 assertTrue(discoveredInstances.Count == 0); // WHEN // It subsequently contacts us when(context.HaveWeContactedInstance(configurationRequestFromTwo)).thenReturn(true); ClusterState.Discovery.handle(context, message, outgoing); // Then assertTrue(discoveredInstances.Contains(configurationRequestFromTwo)); }