Exemplo n.º 1
0
        public void ShouldThrowArgumentNullException_WhenItemParameterIsNull()
        {
            var asyncRepository   = new Mock <IAsyncRepository <IDbModel> >();
            var unitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();

            var genericAsyncService = new GenericAsyncService <IDbModel>(asyncRepository.Object, unitOfWorkFactory.Object);

            IDbModel invalidItem = null;

            Assert.That(
                () => genericAsyncService.Hide(invalidItem),
                Throws.InstanceOf <ArgumentNullException>().With.Message.Contains("Invalid item to hide!"));
        }
Exemplo n.º 2
0
        public void ShouldInvokeUnitOfWorkSaveChangesAsyncMethodOnce_WhenParametersAreCorrect()
        {
            var mockAsyncRepository = new Mock <IAsyncRepository <IDbModel> >();

            var mockUnitOfWork        = new Mock <IDisposableUnitOfWork>();
            var mockUnitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();

            mockUnitOfWorkFactory.Setup(factory => factory.CreateUnitOfWork()).Returns(mockUnitOfWork.Object);

            var genericAsyncService = new GenericAsyncService <IDbModel>(mockAsyncRepository.Object, mockUnitOfWorkFactory.Object);

            var validItem = new Mock <IDbModel>();

            genericAsyncService.Hide(validItem.Object);

            mockUnitOfWork.Verify(repo => repo.SaveChangesAsync(), Times.Once);
        }