Beispiel #1
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 #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);
        }
Beispiel #3
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 #4
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 #5
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 #6
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 #7
0
 public ClientMock(CallInvoker callInvoker, ContractMock contract, Func <CallOptions> defaultCallOptionsFactory)
 {
     CallInvoker = callInvoker;
     Contract    = contract;
     DefaultCallOptionsFactory = defaultCallOptionsFactory;
 }