Esempio n. 1
0
        public void UpdateShouldReturnCorrectValueWhenUpdateDuplicateValueButSameId()
        {
            var service = new ApoClassService(_apoClassRepository, _apoDepartmentRepository);

            var resource = new ApoClassForCreateOrEdit()
            {
                Name            = "Miscellaneous",
                ApoDepartmentId = 1
            };

            var compareObj = new ApoClassDto()
            {
                Name           = resource.Name,
                DepartmentId   = resource.ApoDepartmentId,
                Id             = 91,
                IsActive       = 1,
                Code           = _apoClass.Single(x => x.Id == 91).Code,
                DepartmentName = _apoDepartment.Single(x => x.Id == resource.ApoDepartmentId).Name
            };


            var sut = service.Edit(91, resource);

            Assert.IsType <ApoClassDto>(sut);
            AssertObjects.PropertyValuesAreEquals(sut, compareObj);
        }
Esempio n. 2
0
        public void UpdateShouldThrowErrorWhenUpdateDuplicateValueToCollection()
        {
            var service = new ApoClassService(_apoClassRepository, _apoDepartmentRepository);

            var resource = new ApoClassForCreateOrEdit()
            {
                Name            = "Miscellaneous",
                ApoDepartmentId = 1
            };

            var exception = Record.Exception(() => service.Edit(2, resource));

            Assert.NotNull(exception);
            Assert.IsType <ArgumentException>(exception);
            Assert.True(exception.Message.Contains($"Name {resource.Name} is Already exist."));
        }