Ejemplo n.º 1
0
 private void SetupMocksUpdate(Wallet walletToReturn)
 {
     SetupMockGetUser(fixture.UserWithWallets);
     SetupMockGetWallet(walletToReturn);
     MockUnitOfWork.Setup(x => x.WalletRepository.Update(It.IsAny <Wallet>()));
     MockMapper.Setup(x => x.Map(It.IsAny <UpdateWalletDto>(), It.IsAny <Wallet>()));
 }
Ejemplo n.º 2
0
        private void SetupMockPersitance()
        {
            MockPersistance = new MockPersistance <Dummy>();

            MockUnitOfWork.Setup(_ => _.Complete())
            .Callback(() =>
            {
                var persisted = 0;
                persisted    += MockPersistance.Persist();
                if (persisted == 0)
                {
                    throw new InvalidOperationException("Nothing persisted");
                }
            })
            .Returns(MockPersistance.PersistanceCount);

            MockDummyRepository
            .Setup(_ => _.Create(It.IsAny <Dummy>()))
            .Callback <Dummy>(t => MockPersistance.Create(t))
            .Returns <Dummy>(t => { t.Id = Guid.NewGuid(); return(t); });

            MockDummyRepository
            .Setup(_ => _.QueryEager())
            .Returns(InMemoryDummies.AsQueryable());

            //MockDummyRepository
            //    .Setup(_ => _.Create(It.IsAny<Dummy>()))
            //    .Callback<Dummy>(t => MockPersistance.Create(t))
            //    .Returns<Dummy>(t => { t.Id = Guid.NewGuid(); return t; });

            //MockTaskRepository
            //    .Setup(_ => _.Update(It.IsAny<Task>()))
            //    .Callback<Task>(t => MockPersistance.Update(t))
            //    .Returns<Task>(t => t);
        }
Ejemplo n.º 3
0
 private void SetupMocksCreate(User userToReturn)
 {
     SetupMockGetUser(userToReturn);
     MockUnitOfWork.Setup(x => x.WalletRepository.Create(It.IsAny <Wallet>()));
     MockMapper.Setup(x => x.Map <Wallet>(It.IsAny <WalletDto>())).Returns(fixture.DefaultWallet);
     MockMapper.Setup(x => x.Map <WalletDto>(It.IsAny <Wallet>())).Returns(fixture.DefaultWalletDto);
 }
 private void SetupMocksCrate()
 {
     SetupMocksGeneral();
     MockUnitOfWork.Setup(x => x.CategoryRepository.Create(It.IsAny <MainCategory>()));
     MockMapper.Setup(x => x.Map <MainCategoryDto>(It.IsAny <MainCategory>()))
     .Returns(fixture.CreateCategoryDto);
     MockMapper.Setup(x => x.Map <MainCategory>(It.IsAny <MainCategoryDto>())).Returns(fixture.CreateCategory);
 }
Ejemplo n.º 5
0
 private void SetupMocksGeneral(User repositoryUser, User mapperUser, CreatePasswordDto passwordModel)
 {
     MockUnitOfWork.Setup(x =>
                          x.UserRepository.SingleOrDefaultAsync(It.IsAny <Expression <Func <User, bool> > >()))
     .ReturnsAsync(repositoryUser);
     MockUnitOfWork.Setup(x => x.CommitAsync());
     MockMapper.Setup(x => x.Map <User>(It.IsAny <UserDto>())).Returns(mapperUser);
     mockPasswordService.Setup(x => x.CreatePasswordHash(It.IsAny <string>())).Returns(passwordModel);
 }
Ejemplo n.º 6
0
 private void SetupMocks(Operation createOperation, OperationDto createOperationDto, User user)
 {
     MockUnitOfWork.Setup(x => x.UserRepository.GetAsync(It.IsAny <int>()))
     .ReturnsAsync(user);
     MockUnitOfWork.Setup(x => x.OperationRepository.Create(It.IsAny <Operation>()));
     MockUnitOfWork.Setup(x => x.WalletRepository.Update(It.IsAny <Wallet>()));
     MockUnitOfWork.Setup(x => x.CommitAsync());
     MockMapper.Setup(x => x.Map <Operation>(It.IsAny <OperationDto>())).Returns(createOperation);
     MockMapper.Setup(x => x.Map <OperationDto>(It.IsAny <Operation>())).Returns(createOperationDto);
 }
Ejemplo n.º 7
0
        private void SetupMocksGet <TSource, TDestination>(User userToReturn, TDestination mappedInstance,
                                                           Wallet walletToReturn = null)
        {
            MockUnitOfWork.Setup(x => x.UserRepository.GetAsync(It.IsAny <int>()))
            .ReturnsAsync(userToReturn);
            MockMapper.Setup(x => x.Map <TDestination>(It.IsAny <TSource>()))
            .Returns(mappedInstance);

            if (walletToReturn != null)
            {
                MockUnitOfWork.Setup(x => x.WalletRepository.GetAsync(fixture.DefaultWalletDto.WalletId))
                .ReturnsAsync(walletToReturn);
            }
        }
Ejemplo n.º 8
0
 private void SetupMocksUpdate(User repositoryUser = null)
 {
     SetupMocksGeneral(repositoryUser, fixture.UserForUpdate, fixture.PasswordModelForUpdate);
     MockUnitOfWork.Setup(x => x.UserRepository.Update(It.IsAny <User>()));
 }
 private void SetupMocksUpdate()
 {
     SetupMocksGeneral();
     MockUnitOfWork.Setup(x => x.CategoryRepository.Update(It.IsAny <MainCategory>()));
     MockMapper.Setup(x => x.Map(It.IsAny <UpdateCategoryDto>(), It.IsAny <MainCategory>()));
 }
 private void SetupMocksGeneral()
 {
     MockUnitOfWork.Setup(x => x.UserRepository.GetAsync(It.IsAny <int>()))
     .ReturnsAsync(fixture.UserWithCategories);
     MockUnitOfWork.Setup(x => x.CommitAsync());
 }
Ejemplo n.º 11
0
 private void SetupMocksDelete(Wallet walletToDelete)
 {
     SetupMockGetWallet(walletToDelete);
     MockUnitOfWork.Setup(x => x.WalletRepository.Remove(It.IsAny <Wallet>()));
 }
Ejemplo n.º 12
0
 private void SetupMockGetWallet(Wallet walletToReturn)
 {
     MockUnitOfWork.Setup(x => x.WalletRepository.GetAsync(It.IsAny <int>()))
     .ReturnsAsync(walletToReturn);
     MockUnitOfWork.Setup(x => x.CommitAsync());
 }
Ejemplo n.º 13
0
 private void SetupMockGetUser(User userToReturn)
 {
     MockUnitOfWork.Setup(x => x.UserRepository.GetAsync(It.IsAny <int>())).ReturnsAsync(userToReturn);
     MockUnitOfWork.Setup(x => x.CommitAsync());
 }