public void TryAddWithExistingEndpoint() { 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 newConnection = new EndpointInformation( endpoint, new DiscoveryInformation(new Uri("http://other/discovery/invalid")), new ProtocolInformation( new Version(), new Uri("http://other/protocol/invalid"))); Assert.IsFalse(storage.TryAdd(endpoint, newConnection)); EndpointInformation otherConnection; var result = storage.TryGetConnectionFor(endpoint, out otherConnection); Assert.IsTrue(result); Assert.AreSame(connection, otherConnection); }
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 TryUpdateWithContactedEndpoint() { 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 storage = new EndpointInformationStorage(); Assert.IsTrue(storage.TryAdd(endpoint, connection)); 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 TryAddWithNullEndpoint() { var storage = new EndpointInformationStorage(); 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.IsFalse(storage.TryAdd(null, connection)); }
public void TryAddWithNullConnectionInformation() { var storage = new EndpointInformationStorage(); Assert.IsFalse(storage.TryAdd(new EndpointId("a"), null)); }