public void AfterDecreasingNumNewSessionRequestsFourTimesSendingRequestsIsNoLongerAllowed() { // given var target = new SessionWrapper(wrappedSession); // when decreasing first time target.DecreaseNumNewSessionRequests(); // then sending is still allowed Assert.That(target.CanSendNewSessionRequest, Is.True); // when decreasing second time target.DecreaseNumNewSessionRequests(); // then sending is still allowed Assert.That(target.CanSendNewSessionRequest, Is.True); // when decreasing third time target.DecreaseNumNewSessionRequests(); // then sending is still allowed Assert.That(target.CanSendNewSessionRequest, Is.True); // when decreasing fourth time target.DecreaseNumNewSessionRequests(); // then sending is no longer allowed Assert.That(target.CanSendNewSessionRequest, Is.False); }
public void MultiplicityIsSetToZeroIfNoFurtherNewSessionRequestsAreAllowed() { // given var target = new BeaconSendingCaptureOnState(); var sessionOne = new SessionWrapper(CreateValidSession("127.0.0.1")); var sessionTwo = new SessionWrapper(CreateEmptySession("127.0.0.2")); newSessions.AddRange(new[] { sessionOne, sessionTwo }); httpClient.SendNewSessionRequest().Returns(new StatusResponse("mp=5", 200, new Dictionary <string, List <string> >()), null); // ensure that it's no longer possible to send session requests for both session wrapper while (sessionOne.CanSendNewSessionRequest) { sessionOne.DecreaseNumNewSessionRequests(); } while (sessionTwo.CanSendNewSessionRequest) { sessionTwo.DecreaseNumNewSessionRequests(); } // when target.Execute(context); // verify for no session a new session request has been made httpClient.Received(0).SendNewSessionRequest(); // also ensure that both got a configuration set Assert.That(sessionOne.IsBeaconConfigurationSet, Is.True); Assert.That(sessionOne.BeaconConfiguration.Multiplicity, Is.EqualTo(0)); Assert.That(sessionOne.IsBeaconConfigurationSet, Is.True); Assert.That(sessionOne.BeaconConfiguration.Multiplicity, Is.EqualTo(0)); }