Exemplo n.º 1
0
        public void ApoDivisionServiceShouldReturnNullWhenNameIsAlreadyExist()
        {
            var service = new ApoDivisionService(_apoDivisionRepository, _apoGroupService);

            var newApo = new ApoDivisionForCreateOrEdit()
            {
                Name = "food"
            };



            var exception = Record.Exception(() => service.Create(newApo));

            Assert.NotNull(exception);
            Assert.IsType <ArgumentException>(exception);
            Assert.True(exception.Message.Contains($"Name {newApo.Name} is Already exist."));
        }
Exemplo n.º 2
0
        public void ApoDivisionServiceShouldReturnNewElementWhenCreateSuccess()
        {
            var service = new ApoDivisionService(_apoDivisionRepository, _apoGroupService);

            var newApo = new ApoDivisionForCreateOrEdit()
            {
                Name = "New Apo"
            };


            var nextCode           = (Convert.ToInt32(_apoDivision.Last().Code) + 1).ToString("D2");
            var compareEqualObject = Mapper.Map <ApoDivisionDto>(newApo);

            compareEqualObject.Code = nextCode;
            compareEqualObject.Id   = _apoDivision.Last().Id + 1;

            var sut = service.Create(newApo);

            Assert.Equal(sut.Id, _apoDivision.Last().Id + 1);
            AssertObjects.PropertyValuesAreEquals(sut, compareEqualObject);
        }