Example #1
0
        public void ThrowArgumentNullException_WhenIsPassed_InvalidArgument()
        {
            // Arrange
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var mockedRepo       = new Mock <IEfRepository <ComicsDataModel> >();

            var comicsService = new ComicsService(mockedUnitOfWork.Object, mockedRepo.Object);

            // Act & Assert
            Assert.That(() => comicsService.AddComic(null),
                        Throws.ArgumentNullException.With.Message.Contain("comic"));
        }
Example #2
0
        public void Call_SaveChangesMethod_OfTheUnitOfWork()
        {
            // Arrange
            var comicsDataModels = new List <ComicsDataModel>();
            var comic            = new ComicsDataModel();

            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var mockedRepo       = new Mock <IEfRepository <ComicsDataModel> >();

            mockedRepo.Setup(repo => repo.Add(comic));
            mockedUnitOfWork.Setup(unit => unit.SaveChanges());

            var comicsService = new ComicsService(mockedUnitOfWork.Object, mockedRepo.Object);

            // Act
            comicsService.AddComic(comic);

            // Assert
            mockedUnitOfWork.Verify(unit => unit.SaveChanges(), Times.Once);
        }