コード例 #1
0
        public string Transfer(
            Account debitAccount,
            Account creditAccount,
            decimal amount,
            string motif
            )
        {
            MGuid.NewGuid = () => new Guid("64d80a10-4f21-4acb-9d3d-0332e68c4394");

            PexAssume.IsNotNull(debitAccount);
            PexAssume.IsNotNull(creditAccount);
            PexAssume.IsTrue(creditAccount != debitAccount);
            var repository          = new SIRepository();
            var operationRepository = new SIOperationRepository();
            var operationCreator    = new OperationDtoCreator();

            //act
            var operationServices = new OperationServices(operationRepository, repository, operationCreator);

            operationServices.Transfer(debitAccount, creditAccount, amount, motif);

            string result = operationServices.Transfer(debitAccount, creditAccount, amount, motif);

            PexAssert.IsNotNullOrEmpty(result);
            return(result);
        }
コード例 #2
0
        public void GetOperations_AccountIdIsOk()
        {
            //arrange
            IOperationRepository operationRepository = MockRepository.GenerateMock <IOperationRepository>();
            IRepository          repository          = MockRepository.GenerateStub <IRepository>();
            IDtoCreator <Operation, OperationDto> operationCreator = new OperationDtoCreator();

            List <Operation> operations = new List <Operation>();
            var id = 2;

            operations.Add(new Operation {
                Id = 3
            });
            operationRepository.Expect(x => x.GetOperationsByAccount(id)).Return(operations);


            //act
            OperationServices    services            = new OperationServices(operationRepository, repository, operationCreator);
            IList <OperationDto> retrievedOperations = services.GetOperations(id);

            //assert
            Assert.AreEqual(1, retrievedOperations.Count);
            Assert.AreEqual(3, retrievedOperations[0].Id);
            operationRepository.VerifyAllExpectations();
        }
コード例 #3
0
        public void MakeTransfer(int debitAccountId, int creditAccountId, decimal amount, string motif)
        {
            PexAssume.IsTrue(amount > 100);

            var repository = new SIRepository();
            repository.GetObject<Account>((x) => _accounts.SingleOrDefault(a => a.Id == (int)x));

            var operationRepository = new SIOperationRepository();
            var operationCreator = new OperationDtoCreator();

            //act
            var operationServices = new OperationServices(operationRepository, repository, operationCreator);
            operationServices.MakeTransfer(debitAccountId, creditAccountId, amount, motif);
        }
コード例 #4
0
        public void MakeTransfer(int debitAccountId, int creditAccountId, decimal amount, string motif)
        {
            PexAssume.IsTrue(amount > 100);

            var repository = new SIRepository();

            repository.GetObject <Account>((x) => _accounts.SingleOrDefault(a => a.Id == (int)x));

            var operationRepository = new SIOperationRepository();
            var operationCreator    = new OperationDtoCreator();

            //act
            var operationServices = new OperationServices(operationRepository, repository, operationCreator);

            operationServices.MakeTransfer(debitAccountId, creditAccountId, amount, motif);
        }
コード例 #5
0
        public void GetOperations_AccountIdIsOk()
        {
            //arrange
            IOperationRepository operationRepository = MockRepository.GenerateMock<IOperationRepository>();
            IRepository repository = MockRepository.GenerateStub<IRepository>();
            IDtoCreator<Operation, OperationDto> operationCreator = new OperationDtoCreator();

            List<Operation> operations = new List<Operation>();
            var id = 2;
            operations.Add(new Operation { Id = 3});
            operationRepository.Expect(x=>x.GetOperationsByAccount(id)).Return(operations);

            //act
            OperationServices services = new OperationServices(operationRepository, repository, operationCreator);
            IList<OperationDto> retrievedOperations = services.GetOperations(id);

            //assert
            Assert.AreEqual(1, retrievedOperations.Count);
            Assert.AreEqual(3, retrievedOperations[0].Id);
            operationRepository.VerifyAllExpectations();
        }
コード例 #6
0
        public string Transfer(
            Account debitAccount,
            Account creditAccount,
            decimal amount,
            string motif
        )
        {
            MGuid.NewGuid = () => new Guid("64d80a10-4f21-4acb-9d3d-0332e68c4394");

            PexAssume.IsNotNull(debitAccount);
            PexAssume.IsNotNull(creditAccount);
            PexAssume.IsTrue(creditAccount != debitAccount);
            var repository = new SIRepository();
            var operationRepository = new SIOperationRepository();
            var operationCreator = new OperationDtoCreator();

            //act
            var operationServices = new OperationServices(operationRepository, repository, operationCreator);
            operationServices.Transfer(debitAccount, creditAccount, amount, motif);

            string result = operationServices.Transfer(debitAccount, creditAccount, amount, motif);
            PexAssert.IsNotNullOrEmpty(result);
            return result;
        }