Ejemplo n.º 1
0
        public void Warm_WhenCallPasses_ThenDoNotRetryUrl()
        {
            var config = new Mock<IConfig>();
            config.Setup(m => m.Checks).Returns(new List<Check>
                {
                    new Check
                        {
                            Url = "http://www.google.com"
                        },
                    new Check
                        {
                            Url = "http://www.google.co.uk"
                        }
                });

            var requester = new Mock<IRequester>();
            requester.Setup(m => m.Check(It.IsAny<Check>()))
                     .Callback((Check c) =>
                         {
                             c.Status = c.Url.Equals("http://www.google.com") ? 500 : Check.Ok;
                         });

            var logger = BaseLogger();

            var warmer = new RepeatWarmer(config.Object, requester.Object, logger.Object, 2);

            warmer.Warm();

            requester.Verify(f => f.Check(It.IsAny<Check>()), Times.Exactly(3));
        }
Ejemplo n.º 2
0
        public void Warm_WhenInitialCallFails_ThenRetryOnlyTheNumberOfTimesWeAreConfiguredFor()
        {
            var config = BaseConfig();
            var requester = BaseRequester();
            var logger = BaseLogger();

            var warmer = new RepeatWarmer(config.Object, requester.Object, logger.Object, 1);

            var results = warmer.Warm();

            Assert.That(results.Count, Is.EqualTo(1));

            Assert.AreNotEqual(Check.Ok, results[0].Status);
        }
Ejemplo n.º 3
0
        public void Warm_WhenInitialCallFails_ThenRetry()
        {
            var config = BaseConfig();
            var requester = BaseRequester();
            var logger = BaseLogger();

            var warmer = new RepeatWarmer(config.Object, requester.Object, logger.Object, 2);

            var results = warmer.Warm();

            Assert.That(results.Count, Is.EqualTo(1));

            Assert.That(results[0].Status, Is.EqualTo(Check.Ok));
        }
Ejemplo n.º 4
0
        public void RepeatWarmer_CanBeInitialised()
        {
            var warmer = new RepeatWarmer(null, null, null, 1);

            Assert.That(warmer, Is.InstanceOf<RepeatWarmer>());
        }