public void GetAnyQuoteTest_NotActor_ReturnRandom()
        {
            var fakeService        = new QuoteService(fakeContext.Object, new RandomService());
            var controller         = new QuoteController(fakeService);
            var actualActionResult = controller.GetAnyQuote();
            var actual             = actualActionResult.Value;

            Assert.InRange(actual.Id, fakeContext.Object.Quotes.First().Id, fakeContext.Object.Quotes.Last().Id);
        }
        public void GetAnyQuoteTest_Actor_ReturnRandom()
        {
            var fakeService        = new QuoteService(fakeContext.Object, new RandomService());
            var controller         = new QuoteController(fakeService);
            var actualActionResult = controller.GetAnyQuote("Graham");
            var expected           = fakeContext.Object.Quotes.FirstOrDefault(x => x.Id == 3);
            var actual             = actualActionResult.Value;

            Assert.Equal(expected.Id, actual.Id);
        }
        public void Should_Returns_Not_Found_When_Get_Any_Quote_By_Non_Exists_Actor()
        {
            var fakeService = new QuoteService(fakeContext.Object, new RandomService());
            var controller  = new QuoteController(fakeService);

            var actual = controller.GetAnyQuote("Brian");

            Assert.NotNull(actual);
            Assert.IsType <NotFoundResult>(actual.Result);
        }
Exemplo n.º 4
0
        public void Should_Returns_Not_Found_When_Get_Any_Quote_By_Non_Exists_Actor()
        {
            var fakeRandom = new Mock <IRandomService>();

            fakeRandom.Setup(x => x.RandomInteger(It.IsAny <int>())).Returns(0);
            var fakeService = new QuoteService(fakeContext.Object, fakeRandom.Object);
            var controller  = new QuoteController(fakeService);

            var actual = controller.GetAnyQuote("Brian");

            Assert.NotNull(actual);
            Assert.IsType <NotFoundResult>(actual.Result);
        }
        public void Should_Returns_Random_Quote_When_Get_Any_By_Actor()
        {
            var fakeRandom = new Mock <IRandomService>();

            fakeRandom.Setup(x => x.RandomInteger(It.IsAny <int>())).Returns(0);
            var fakeService = new QuoteService(fakeContext.Object, fakeRandom.Object);
            var controller  = new QuoteController(fakeService);

            var actual = controller.GetAnyQuote("Eric");

            Assert.NotNull(actual);
            Assert.IsNotType <NotFoundResult>(actual.Result);
            Assert.Equal("Eric", actual.Value.Actor);
            Assert.Equal(1, actual.Value.Id);
            Assert.Equal("Ni", actual.Value.Detail);
        }