Beispiel #1
0
        public void CarrierUpdateEntityWithNameEmpty()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = CarrierMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

            var key2 = Fake.GetKey();

            var model = CarrierInputModelMock.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 <Carrier>().ToList();
            var entityExpected = CarrierMock.Get(key);

            entities.Should().BeEquivalentToEntity(new List <Carrier>()
            {
                entityExpected
            });
        }
Beispiel #2
0
        public void CarrierUpdateEntityValid()
        {
            // arrange
            var key = Fake.GetKey();

            var entity = CarrierMock.Get(key);

            MockRepository.Add(entity);

            MockRepository.Commit();

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

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

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

            entities.Should().BeEquivalentToEntity(new List <Carrier>()
            {
                entityExpected
            });
        }
Beispiel #3
0
        public void CarrierUpdateWithoutEntity()
        {
            // arrange
            var key = Fake.GetKey();

            var key2 = Fake.GetKey();

            var model = CarrierInputModelMock.Get(key2);

            // act
            Action action = () => Update(Fake.GetId(key), model);

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

            var model = CarrierInputModelMock.Get(key);

            model.Name = null;

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

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

            var entities = MockRepository.Query <Carrier>().ToList();

            entities.Should().BeEmpty();
        }