예제 #1
0
        public void ContractFindShortestPathTwoEntityWithContractFinished()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            MockRepository.Add(carrier);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            MockRepository.Add(mga);

            var contract = ContractMock.Get(carrier.Id, mga.Id);

            contract.Finished = true;

            MockRepository.Add(contract);

            MockRepository.Commit();

            var model = ContractInputModelMock.Get(carrier.Id, mga.Id);

            // act
            var result = FindShortestPath(model);

            // assertation
            result.Should().BeEmpty();
        }
예제 #2
0
        public void ContractFindShortestPathWithIdEquals()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            MockRepository.Add(carrier);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            MockRepository.Add(mga);

            var contract = ContractMock.Get(carrier.Id, mga.Id);

            MockRepository.Add(contract);

            MockRepository.Commit();

            var model = ContractInputModelMock.Get(carrier.Id, carrier.Id);

            // act
            Action action = () => FindShortestPath(model);

            // assertation
            action.Should().Throw <ValidationBusinessException>().WithMessage(ValidationMessage.ContractInvalid);
        }
예제 #3
0
        public void ContractFindShortestPathTwoEntityValid()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            MockRepository.Add(carrier);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            MockRepository.Add(mga);

            var contract = ContractMock.Get(carrier.Id, mga.Id);

            MockRepository.Add(contract);

            MockRepository.Commit();

            var model = ContractInputModelMock.Get(carrier.Id, mga.Id);

            // act
            var result = FindShortestPath(model);

            // assertation
            var carrierViewModelExpected1 = ContractPartViewModelMock.Get(key);
            var carrierViewModelExpected2 = ContractPartViewModelMock.Get(key2);

            result.Should().BeEquivalentTo(new List <ContractPartViewModel>()
            {
                carrierViewModelExpected1, carrierViewModelExpected2
            });
        }
예제 #4
0
        public void ContractTerminateContractNotExists()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            MockRepository.Add(carrier);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            MockRepository.Add(mga);

            MockRepository.Commit();

            var model = ContractInputModelMock.Get(carrier.Id, mga.Id);

            // act
            Action action = () => Terminate(model);

            // assertation
            action.Should().Throw <ValidationBusinessException>().WithMessage(ValidationMessage.ContractNotExists);

            var contracts = MockRepository.Query <Contract>().ToList();

            contracts.Should().BeEmpty();
        }
예제 #5
0
        public void ContractEstablishTwoEntityValid()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            MockRepository.Add(carrier);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            MockRepository.Add(mga);

            MockRepository.Commit();

            var model = ContractInputModelMock.Get(carrier.Id, mga.Id);

            // act
            Establish(model);

            // assertation
            var contracts        = MockRepository.Query <Contract>().ToList();
            var contractExpected = ContractMock.Get(carrier.Id, mga.Id);

            contracts.Should().BeEquivalentToEntity(new List <Contract>()
            {
                contractExpected
            });
        }
예제 #6
0
        public void ContractTerminateWithIdEquals()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            MockRepository.Add(carrier);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            MockRepository.Add(mga);

            var contract = ContractMock.Get(carrier.Id, mga.Id);

            MockRepository.Add(contract);

            MockRepository.Commit();

            var model = ContractInputModelMock.Get(carrier.Id, carrier.Id);

            // act
            Action action = () => Terminate(model);

            // assertation
            action.Should().Throw <ValidationBusinessException>().WithMessage(ValidationMessage.ContractInvalid);

            var contracts        = MockRepository.Query <Contract>().ToList();
            var contractExpected = ContractMock.Get(carrier.Id, mga.Id);

            contracts.Should().BeEquivalentToEntity(new List <Contract>()
            {
                contractExpected
            });
        }
예제 #7
0
        public void ContractEstablishWithToIdEmpty()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            MockRepository.Add(carrier);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            MockRepository.Add(mga);

            MockRepository.Commit();

            var model = ContractInputModelMock.Get(carrier.Id, Guid.Empty);

            // act
            Action action = () => Establish(model);

            // assertation
            action.Should().Throw <ValidationBusinessException>().WithMessage(ValidationMessage.IdInvalid);

            var contracts = MockRepository.Query <Contract>().ToList();

            contracts.Should().BeEmpty();
        }
예제 #8
0
        public void ContractFindShortestPathComplex()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            MockRepository.Add(carrier);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            MockRepository.Add(mga);

            var key3    = Fake.GetKey();
            var advisor = AdvisorMock.Get(key3);

            MockRepository.Add(advisor);

            var contract1 = ContractMock.Get(carrier.Id, mga.Id);

            MockRepository.Add(contract1);

            var contract2 = ContractMock.Get(mga.Id, advisor.Id);

            MockRepository.Add(contract2);

            var contract3 = ContractMock.Get(carrier.Id, advisor.Id);

            MockRepository.Add(contract3);

            MockRepository.Commit();

            var model = ContractInputModelMock.Get(carrier.Id, advisor.Id);

            // act
            var result = FindShortestPath(model);

            // assertation
            var carrierViewModelExpected1 = ContractPartViewModelMock.Get(key);
            var carrierViewModelExpected3 = ContractPartViewModelMock.Get(key3);

            result.Should().BeEquivalentTo(new List <ContractPartViewModel>()
            {
                carrierViewModelExpected1, carrierViewModelExpected3
            });
        }
예제 #9
0
        public void ContractFindShortestPathWithoutContractParts()
        {
            // arrange
            var key     = Fake.GetKey();
            var carrier = CarrierMock.Get(key);

            var key2 = Fake.GetKey();
            var mga  = MgaMock.Get(key2);

            var model = ContractInputModelMock.Get(carrier.Id, mga.Id);

            // act
            var result = FindShortestPath(model);

            // assertation
            result.Should().BeEmpty();
        }