예제 #1
0
        public void Call_RepositoryGetByIdMethodOnceWithCorrectParams()
        {
            var id            = this.Fixture.Create <string>();
            var repository    = new Mock <IRepository <BeerReview> >();
            var reviewService = new BeerReviewService(repository.Object);

            reviewService.GetById(id);

            repository.Verify(r => r.GetById(id), Times.Once);
        }
예제 #2
0
        public void ReturnResultFrom_RepositoryGetByIdMethod()
        {
            var id         = this.Fixture.Create <string>();
            var expected   = new BeerReview();
            var repository = new Mock <IRepository <BeerReview> >();

            repository.Setup(r => r.GetById(It.IsAny <object>()))
            .Returns(expected);

            var reviewService = new BeerReviewService(repository.Object);

            var actual = reviewService.GetById(id);

            Assert.AreSame(expected, actual);
        }