Beispiel #1
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);
        }
Beispiel #2
0
        public void ContractGetAllEntities()
        {
            // 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();

            // act
            var result = GetAll();

            // assertation
            var contractViewModelExpected = ContractViewModelMock.Get(carrier, mga);

            result.Should().BeEquivalentTo(new List <ContractViewModel>()
            {
                contractViewModelExpected
            });
        }
Beispiel #3
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();
        }
Beispiel #4
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
            });
        }
Beispiel #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
            });
        }
Beispiel #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
            });
        }
Beispiel #7
0
        public void ContractGetNodesWithContractFinished()
        {
            // 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();

            // act
            var result = GetNodes();

            // assertation
            var nodeViewModelExpected1 = NodeViewModelMock.Get(key);
            var nodeViewModelExpected2 = NodeViewModelMock.Get(key2);

            result.Should().BeEquivalentTo(new List <NodeViewModel>()
            {
                nodeViewModelExpected1, nodeViewModelExpected2
            });
        }
Beispiel #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
            });
        }
Beispiel #9
0
        public void ContractGetNodesPartWithTwoContracts()
        {
            // 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(carrier.Id, advisor.Id);

            MockRepository.Add(contract2);

            MockRepository.Commit();

            // act
            var result = GetNodes();

            // assertation
            var nodeViewModelExpected1 = NodeViewModelMock.Get(key);
            var nodeViewModelExpected2 = NodeViewModelMock.Get(key2);
            var nodeViewModelExpected3 = NodeViewModelMock.Get(key3);

            result.Should().BeEquivalentTo(new List <NodeViewModel>()
            {
                nodeViewModelExpected1, nodeViewModelExpected2, nodeViewModelExpected3
            });
        }
Beispiel #10
0
        public void MgaDeleteEntityWithContract()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = MgaMock.Get(key);

            MockRepository.Add(entity);

            var key2 = Fake.GetKey();

            var entity2 = MgaMock.Get(key2);

            MockRepository.Add(entity2);

            var contract = ContractMock.Get(entity.Id, entity2.Id);

            MockRepository.Add(contract);

            MockRepository.Commit();

            // act
            Delete(entity.Id);

            // assertation
            var entities       = MockRepository.Query <Mga>().ToList();
            var entityExpected = MgaMock.Get(key2);

            entities.Should().BeEquivalentToEntity(new List <Mga>()
            {
                entityExpected
            });

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

            contracts.Should().BeEmpty();
        }