Beispiel #1
0
        public void ContractDomainService_CreateContract_NoOperatorCreatedForEstate_ErrorThrown()
        {
            Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> > estateAggregateRepository = new Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >();

            estateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(TestData.CreatedEstateAggregate);
            Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> > contractAggregateRepository = new Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> >();

            ContractDomainService domainService = new ContractDomainService(estateAggregateRepository.Object, contractAggregateRepository.Object);

            Should.Throw <InvalidOperationException>(async() =>
            {
                await domainService.CreateContract(TestData.ContractId,
                                                   TestData.EstateId,
                                                   TestData.OperatorId,
                                                   TestData.ContractDescription,
                                                   CancellationToken.None);
            });
        }
Beispiel #2
0
        public async Task ContractDomainService_DisableTransactionFeeForProduct_TransactionFeeDisabled(CalculationType calculationType, FeeType feeType)
        {
            Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >   estateAggregateRepository   = new Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >();
            Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> > contractAggregateRepository = new Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> >();

            contractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(TestData.CreatedContractAggregateWithAProductAndTransactionFee(calculationType, feeType));

            ContractDomainService domainService = new ContractDomainService(estateAggregateRepository.Object, contractAggregateRepository.Object);

            Should.NotThrow(async() =>
            {
                await domainService.DisableTransactionFeeForProduct(TestData.TransactionFeeId,
                                                                    TestData.ContractId,
                                                                    TestData.ProductId,
                                                                    CancellationToken.None);
            });
        }
Beispiel #3
0
        public async Task ContractDomainService_AddProductToContract_VariableValue_ContractNotCreated_ErrorThrown()
        {
            Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >   estateAggregateRepository   = new Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >();
            Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> > contractAggregateRepository = new Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> >();

            contractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(TestData.EmptyContractAggregate);

            ContractDomainService domainService = new ContractDomainService(estateAggregateRepository.Object, contractAggregateRepository.Object);

            Should.Throw <InvalidOperationException>(async() =>
            {
                await domainService.AddProductToContract(TestData.ProductId,
                                                         TestData.ContractId,
                                                         TestData.ProductName,
                                                         TestData.ProductDisplayText,
                                                         null,
                                                         CancellationToken.None);
            });
        }
Beispiel #4
0
        public async Task ContractDomainService_AddProductToContract_FixedValue_ProductAddedToContract()
        {
            Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >   estateAggregateRepository   = new Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >();
            Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> > contractAggregateRepository = new Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> >();

            contractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(TestData.CreatedContractAggregate);

            ContractDomainService domainService = new ContractDomainService(estateAggregateRepository.Object, contractAggregateRepository.Object);

            Should.NotThrow(async() =>
            {
                await domainService.AddProductToContract(TestData.ProductId,
                                                         TestData.ContractId,
                                                         TestData.ProductName,
                                                         TestData.ProductDisplayText,
                                                         TestData.ProductFixedValue,
                                                         CancellationToken.None);
            });
        }
Beispiel #5
0
        public void ContractDomainService_CreateContract_ContractIsCreated()
        {
            Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> > estateAggregateRepository = new Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >();

            estateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(TestData.EstateAggregateWithOperator());
            Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> > contractAggregateRepository = new Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> >();

            contractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(TestData.EmptyContractAggregate);

            ContractDomainService domainService = new ContractDomainService(estateAggregateRepository.Object, contractAggregateRepository.Object);

            Should.NotThrow(async() =>
            {
                await domainService.CreateContract(TestData.ContractId,
                                                   TestData.EstateId,
                                                   TestData.OperatorId,
                                                   TestData.ContractDescription,
                                                   CancellationToken.None);
            });
        }
Beispiel #6
0
        public async Task ContractDomainService_AddTransactionFeeForProductToContract_ProductNotFound_ErrorThrown(CalculationType calculationType, FeeType feeType)
        {
            Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >   estateAggregateRepository   = new Mock <IAggregateRepository <EstateAggregate, DomainEventRecord.DomainEvent> >();
            Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> > contractAggregateRepository = new Mock <IAggregateRepository <ContractAggregate, DomainEventRecord.DomainEvent> >();

            contractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(TestData.CreatedContractAggregateWithAProduct);

            ContractDomainService domainService = new ContractDomainService(estateAggregateRepository.Object, contractAggregateRepository.Object);

            Should.Throw <InvalidOperationException>(async() =>
            {
                await domainService.AddTransactionFeeForProductToContract(TestData.TransactionFeeId,
                                                                          TestData.ContractId,
                                                                          Guid.Parse("63662476-6C0F-42A8-BFD6-0C2F4B4D3144"),
                                                                          TestData.TransactionFeeDescription,
                                                                          calculationType,
                                                                          feeType,
                                                                          TestData.TransactionFeeValue,
                                                                          CancellationToken.None);
            });
        }