示例#1
0
        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();
        }