예제 #1
0
        public void Should_Returns_Null_When_Get_Any_Quote_By_Non_Exists_Actor()
        {
            var fakeService = new QuoteService(fakeContext.Object, new RandomService());
            var actual      = fakeService.GetAnyQuote("Brian");

            Assert.Null(actual);
        }
예제 #2
0
        public void Should_Returns_Any_Quote_When_Get_Any_Quote()
        {
            var fakeService = new QuoteService(fakeContext.Object, new RandomService());
            var actual      = fakeService.GetAnyQuote();

            Assert.NotNull(actual);
        }
        public void Should_Returns_Null_When_Get_Any_Quote_By_Actor()
        {
            var fakeService = new QuoteService(fakeContext.Object, new RandomService());
            var actual      = fakeService.GetAnyQuote("Eric");

            //Assert.NotNull(actual);
            Assert.Equal("Eric", actual.Actor);
        }
예제 #4
0
        public void Should_Returns_Any_Quote_When_Get_Any_Quote_By_Actor()
        {
            var fakeRandom = new Mock <IRandomService>();

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

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

            Assert.NotNull(actual);
            Assert.Equal("Eric", actual.Actor);
            Assert.Equal(1, actual.Id);
            Assert.Equal("Ni", actual.Detail);
        }
예제 #5
0
        public void GetAnyQuoteTest_NotActor_ReturnRandom()
        {
            var fakeService = new QuoteService(fakeContext.Object, new RandomService());
            var quoteRandom = new List <Quote>();

            for (var i = 0; i < 100; i++)
            {
                quoteRandom.Add(fakeService.GetAnyQuote());
            }

            foreach (var quote in fakeContext.Object.Quotes)
            {
                Assert.Contains(quote, quoteRandom, new QuoteIdComparer());
            }
        }
예제 #6
0
        public void GetAnyQuoteTest_Actor_ReturnRandom()
        {
            var  fakeService = new QuoteService(fakeContext.Object, new RandomService());
            long totalId3    = 0;

            for (var i = 0; i < 100; i++)
            {
                if (fakeService.GetAnyQuote("Graham").Id == 3)
                {
                    totalId3++;
                }
            }

            Assert.True(totalId3 > 35 && totalId3 < 65);
        }