Beispiel #1
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 #2
0
        public void MgaUpdateEntityValid()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = MgaMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

            var key2  = Fake.GetKey();
            var model = MgaInputModelMock.Get(key2);

            // act
            Update(entity.Id, model);

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

            entities.Should().BeEquivalentToEntity(new List <Mga>()
            {
                entityExpected
            });
        }
Beispiel #3
0
        public void ContractEstablishWithInputNull()
        {
            // 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.Null;

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

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

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

            contracts.Should().BeEmpty();
        }
Beispiel #4
0
        public void AdvisoDeleteEntityWithIdEmpty()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = MgaMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

            // act
            Action action = () => Delete(Guid.Empty);

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

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

            entities.Should().BeEquivalentToEntity(new List <Mga>()
            {
                entityExpected
            });
        }
Beispiel #5
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 #6
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 #7
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 #8
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();
        }
Beispiel #9
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 #10
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 #11
0
        public void MgaUpdateEntityWithNameEmpty()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = MgaMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

            var key2 = Fake.GetKey();

            var model = MgaInputModelMock.Get(key2);

            model.Name = string.Empty;

            // act
            Action action = () => Update(entity.Id, model);

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

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

            entities.Should().BeEquivalentToEntity(new List <Mga>()
            {
                entityExpected
            });
        }
Beispiel #12
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 #13
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();
        }
Beispiel #14
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 #15
0
        public void MgaGetEntityWithIdEmpty()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = MgaMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

            // act
            Action action = () => Get(Guid.Empty);

            // assertation
            action.Should().Throw <ValidationBusinessException>().WithMessage(ValidationMessage.IdInvalid);
        }
Beispiel #16
0
        public void MgaDeleteEntityValid()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = MgaMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

            // act
            Delete(entity.Id);

            // assertation
            var entities = MockRepository.Query <Mga>().ToList();

            entities.Should().BeEmpty();
        }
Beispiel #17
0
        public void MgaGetEntityValid()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = MgaMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

            // act
            var result = Get(entity.Id);

            // assertation
            var viewModelExpected = MgaViewModelMock.Get(key);

            result.Should().BeEquivalentTo(viewModelExpected);
        }
Beispiel #18
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 #19
0
        public void MgaGetAllEntities()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = MgaMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

            // act
            var result = GetAll();

            // assertation
            var viewModelExpected = MgaViewModelMock.Get(key);

            result.Should().BeEquivalentTo(new List <MgaViewModel>()
            {
                viewModelExpected
            });
        }
Beispiel #20
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();
        }