public void Can_put_to_sleep_by_contexts() { PeerInfo peerInfo = new PeerInfo(Substitute.For <ISyncPeer>()); for (int i = 0; i < PeerInfo.SleepThreshold - 1; i++) { AllocationContexts sleeps = peerInfo.IncreaseWeakness(_contexts); sleeps.Should().Be(AllocationContexts.None); } AllocationContexts sleeps2 = peerInfo.IncreaseWeakness(_contexts); sleeps2.Should().Be(_contexts); }
public void Can_put_to_sleep() { PeerInfo peerInfo = new PeerInfo(Substitute.For <ISyncPeer>()); for (int i = 0; i < PeerInfo.SleepThreshold - 1; i++) { AllocationContexts sleeps = peerInfo.IncreaseWeakness(_contexts); sleeps.Should().Be(AllocationContexts.None); } AllocationContexts sleeps2 = peerInfo.IncreaseWeakness(_contexts); sleeps2.Should().Be(_contexts); peerInfo.PutToSleep(sleeps2, DateTime.MinValue); peerInfo.IsAsleep(_contexts).Should().BeTrue(); }
public void Can_wake_up() { PeerInfo peerInfo = new(Substitute.For <ISyncPeer>()); for (int i = 0; i < PeerInfo.SleepThreshold - 1; i++) { AllocationContexts sleeps = peerInfo.IncreaseWeakness(_contexts); sleeps.Should().Be(AllocationContexts.None); } AllocationContexts sleeps2 = peerInfo.IncreaseWeakness(_contexts); sleeps2.Should().Be(_contexts); peerInfo.PutToSleep(sleeps2, DateTime.MinValue); peerInfo.IsAsleep(_contexts).Should().BeTrue(); peerInfo.TryToWakeUp(DateTime.MinValue, TimeSpan.Zero); peerInfo.IsAsleep(_contexts).Should().BeFalse(); }