public void EndpointRegistry_should_keep_refuseUid_after_register_new_Endpoint() { var reg = new EndpointRegistry(); var deadline = Deadline.Now + TimeSpan.FromMinutes(30); reg.RegisterWritableEndpoint(address1, actorA, null); reg.MarkAsQuarantined(address1, 42, deadline); reg.RefuseUid(address1).Should().Be(42); reg.IsQuarantined(address1, 42).Should().BeTrue(); reg.UnregisterEndpoint(actorA); // Quarantined marker is kept so far var policy = reg.WritableEndpointWithPolicyFor(address1); policy.Should().BeOfType <EndpointManager.Quarantined>(); policy.AsInstanceOf <EndpointManager.Quarantined>().Uid.Should().Be(42); policy.AsInstanceOf <EndpointManager.Quarantined>().Deadline.Should().Be(deadline); reg.RefuseUid(address1).Should().Be(42); reg.IsQuarantined(address1, 42).Should().BeTrue(); reg.RegisterWritableEndpoint(address1, actorB, null); // Quarantined marker is gone var policy2 = reg.WritableEndpointWithPolicyFor(address1); policy2.Should().BeOfType <EndpointManager.Pass>(); policy2.AsInstanceOf <EndpointManager.Pass>().Endpoint.Should().Be(actorB); // but we still have the refuseUid reg.RefuseUid(address1).Should().Be(42); reg.IsQuarantined(address1, 42).Should().BeTrue(); }
public void EndpointRegistry_must_keep_tombstones_when_removing_an_endpoint() { var reg = new EndpointRegistry(); reg.RegisterWritableEndpoint(address1, actorA); reg.RegisterWritableEndpoint(address2, actorB); var deadline = Deadline.Now; reg.MarkAsFailed(actorA, deadline); reg.MarkAsQuarantined(address2, 42, deadline); reg.UnregisterEndpoint(actorA); reg.UnregisterEndpoint(actorB); Assert.Equal(deadline, reg.WritableEndpointWithPolicyFor(address1).AsInstanceOf <EndpointManager.Gated>().TimeOfRelease); Assert.Equal(deadline, reg.WritableEndpointWithPolicyFor(address2).AsInstanceOf <EndpointManager.Quarantined>().Deadline); Assert.Equal(42, reg.WritableEndpointWithPolicyFor(address2).AsInstanceOf <EndpointManager.Quarantined>().Uid); }
public void EndpointRegistry_must_keep_tombstones_when_removing_an_endpoint() { var reg = new EndpointRegistry(); reg.RegisterWritableEndpoint(address1, actorA); reg.RegisterWritableEndpoint(address2, actorB); var deadline = Deadline.Now; reg.MarkAsFailed(actorA, deadline); reg.MarkAsQuarantined(address2, 42, deadline); reg.UnregisterEndpoint(actorA); reg.UnregisterEndpoint(actorB); Assert.Equal(deadline, reg.WritableEndpointWithPolicyFor(address1).AsInstanceOf<EndpointManager.Gated>().TimeOfRelease); Assert.Equal(deadline, reg.WritableEndpointWithPolicyFor(address2).AsInstanceOf<EndpointManager.Quarantined>().Deadline); Assert.Equal(42, reg.WritableEndpointWithPolicyFor(address2).AsInstanceOf<EndpointManager.Quarantined>().Uid); }