public void TryRemoveWithApprovedEndpoint() { var storage = new EndpointInformationStorage(); var endpoint = new EndpointId("a"); var connection = new EndpointInformation( new EndpointId("a"), new DiscoveryInformation(new Uri("http://localhost/discovery/invalid")), new ProtocolInformation( new Version(), new Uri("http://localhost/protocol/invalid"))); Assert.IsTrue(storage.TryAdd(endpoint, connection)); Assert.IsFalse(storage.CanCommunicateWithEndpoint(endpoint)); Assert.IsTrue(storage.HasBeenContacted(endpoint)); Assert.IsFalse(storage.IsWaitingForApproval(endpoint)); var description = new ProtocolDescription(new List <CommunicationSubject>()); Assert.IsTrue(storage.TryStartApproval(endpoint, description)); Assert.IsTrue(storage.TryCompleteApproval(endpoint)); Assert.IsTrue(storage.CanCommunicateWithEndpoint(endpoint)); Assert.IsFalse(storage.IsWaitingForApproval(endpoint)); Assert.IsTrue(storage.TryRemoveEndpoint(endpoint)); Assert.IsFalse(storage.CanCommunicateWithEndpoint(endpoint)); Assert.IsFalse(storage.IsWaitingForApproval(endpoint)); Assert.IsFalse(storage.HasBeenContacted(endpoint)); }
public void TryUpdateWithApprovalUnderWay() { var endpoint = new EndpointId("a"); var connection = new EndpointInformation( new EndpointId("a"), new DiscoveryInformation(new Uri("http://localhost/discovery/invalid")), new ProtocolInformation( new Version(), new Uri("http://localhost/protocol/invalid"))); var description = new ProtocolDescription(new List <CommunicationSubject>()); var storage = new EndpointInformationStorage(); Assert.IsTrue(storage.TryAdd(endpoint, connection)); Assert.IsTrue(storage.TryStartApproval(endpoint, description)); var newConnection = new EndpointInformation( endpoint, new DiscoveryInformation(new Uri("http://other/discovery/invalid")), new ProtocolInformation( new Version(), new Uri("http://other/protocol/invalid"))); Assert.IsTrue(storage.TryUpdate(newConnection)); EndpointInformation storedConnection; storage.TryGetConnectionFor(endpoint, out storedConnection); Assert.AreSame(newConnection, storedConnection); }
public void TryApprove() { var endpoint = new EndpointId("a"); var connection = new EndpointInformation( new EndpointId("a"), new DiscoveryInformation(new Uri("http://localhost/discovery/invalid")), new ProtocolInformation( new Version(), new Uri("http://localhost/protocol/invalid"))); var description = new ProtocolDescription(new List <CommunicationSubject>()); var storage = new EndpointInformationStorage(); var wasApproved = false; storage.OnEndpointConnected += (s, e) => { wasApproved = true; Assert.AreSame(connection.Id, e.Endpoint); }; Assert.IsTrue(storage.TryAdd(endpoint, connection)); Assert.IsFalse(storage.CanCommunicateWithEndpoint(endpoint)); Assert.IsTrue(storage.HasBeenContacted(endpoint)); Assert.IsFalse(storage.IsWaitingForApproval(endpoint)); Assert.IsTrue(storage.TryStartApproval(endpoint, description)); Assert.IsTrue(storage.TryCompleteApproval(endpoint)); Assert.IsTrue(storage.CanCommunicateWithEndpoint(endpoint)); Assert.IsFalse(storage.HasBeenContacted(endpoint)); Assert.IsFalse(storage.IsWaitingForApproval(endpoint)); Assert.IsTrue(wasApproved); }
public void TryStartApproveWithNullDescription() { var storage = new EndpointInformationStorage(); var endpoint = new EndpointId("a"); Assert.IsFalse(storage.TryStartApproval(endpoint, null)); }
public void TryStartApproveWithNullEndpoint() { var storage = new EndpointInformationStorage(); var description = new ProtocolDescription(new List <CommunicationSubject>()); Assert.IsFalse(storage.TryStartApproval(null, description)); }