Example #1
0
        public void ReturnNullWhenIdNotFound()
        {
            var options  = TestUtilities.GetOptions(nameof(ReturnNullWhenIdNotFound));
            int resultId = -1;
            var review   = new BarReview
            {
                Id = resultId,
            };

            using (var actContext = new CocktailDB(options))
            {
                actContext.AddAsync(review).GetAwaiter();
                actContext.SaveChangesAsync().GetAwaiter();
            }
            using (var assertContext = new CocktailDB(options))
            {
                var sut    = new BarReviewServices(assertContext);
                var result = sut.GetBarReviewAsync(int.MaxValue).GetAwaiter().GetResult();
                Assert.IsNull(result);
            }
        }
Example #2
0
        public void ReturnCorrectReview()
        {
            var options  = TestUtilities.GetOptions(nameof(ReturnCorrectReview));
            int resultId = -1;
            var review   = new BarReview
            {
                Id = resultId,
            };

            using (var actContext = new CocktailDB(options))
            {
                actContext.AddAsync(review).GetAwaiter();
                actContext.SaveChangesAsync().GetAwaiter();
            }
            using (var assertContext = new CocktailDB(options))
            {
                var sut    = new BarReviewServices(assertContext);
                var result = sut.GetBarReviewAsync(resultId).GetAwaiter().GetResult();
                Assert.IsNotNull(result);
                Assert.AreEqual(resultId, result.Id);
            }
        }