Exemple #1
0
        public void NewSessionRequestsAreMadeForAllNewSessions()
        {
            // 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,
                                                       new StatusResponse("mp=3", 200, new Dictionary <string, List <string> >()));

            // when
            target.Execute(context);

            // verify for both new sessions a new session request has been made
            httpClient.Received(2).SendNewSessionRequest();

            // also verify that sessionOne got a new configuration
            Assert.That(sessionOne.IsBeaconConfigurationSet, Is.True);
            Assert.That(sessionOne.BeaconConfiguration.Multiplicity, Is.EqualTo(5));

            // for session two the number of requests was decremented
            Assert.That(sessionTwo.IsBeaconConfigurationSet, Is.False);
            Assert.That(sessionTwo.NumNewSessionRequestsLeft, Is.EqualTo(3));
        }