public void ShouldInvokeAsyncRepository_CorrectGetAllWithCorrectFilterExpression()
        {
            var mockAsyncRepository   = new Mock <IAsyncRepository <IDbModel> >();
            var mockUnitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();

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

            genericAsyncService.GetDeleted();

            mockAsyncRepository.Verify(repo => repo.GetAll((x) => x.IsDeleted), Times.Once);
        }
        public void ShouldInvokeAsyncRepository_CorrectGetAllOnce()
        {
            var mockAsyncRepository   = new Mock <IAsyncRepository <IDbModel> >();
            var mockUnitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();

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

            genericAsyncService.GetDeleted();

            mockAsyncRepository.Verify(repo => repo.GetAll(It.IsAny <Expression <Func <IDbModel, bool> > >()), Times.Once);
        }
        public void ShouldReturnTheResultOfTheRepositoryTask()
        {
            var mockUnitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();
            var mockAsyncRepository   = new Mock <IAsyncRepository <IDbModel> >();
            IEnumerable <IDbModel> repositoryQueryResult = new List <IDbModel>();

            mockAsyncRepository.Setup(repo => repo.GetAll(It.IsAny <Expression <Func <IDbModel, bool> > >())).Returns(() => Task.Run(() => repositoryQueryResult));

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

            var actualResult = genericAsyncService.GetDeleted();

            Assert.That(actualResult, Is.SameAs(repositoryQueryResult));
        }
        public void ShouldReturnValueOfCorrectType()
        {
            var mockUnitOfWorkFactory = new Mock <IDisposableUnitOfWorkFactory>();
            var mockAsyncRepository   = new Mock <IAsyncRepository <IDbModel> >();

            mockAsyncRepository.Setup(repo => repo.GetAll(It.IsAny <Expression <Func <IDbModel, bool> > >())).Returns(() =>
            {
                IEnumerable <IDbModel> result = new List <IDbModel>();
                return(Task.Run(() => result));
            });

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

            var actualResult = genericAsyncService.GetDeleted();

            Assert.That(actualResult, Is.InstanceOf <IEnumerable <IDbModel> >());
        }