public void OrganizationDepartmentDto_Extension_AsEntity_Null()
        {
            OrganizationDepartmentDto organizationDepartment = null;
            var result = organizationDepartment.AsEntity();

            Assert.IsNull(result);
            Assert.AreEqual(null, result);
        }
        public void OrganizationDepartmentDto_Property_Created()
        {
            var organizationDepartment = new OrganizationDepartmentDto();
            var value = DateTime.Now;

            organizationDepartment.Created = value;

            Assert.IsNotNull(organizationDepartment.Created);
            Assert.IsInstanceOfType(organizationDepartment.Created, typeof(DateTime));
            Assert.AreEqual(value, organizationDepartment.Created);
        }
        public void OrganizationDepartmentDto_Property_Address()
        {
            var organizationDepartment = new OrganizationDepartmentDto();
            var value = Core.Tests.TestHelper.AddressDto();

            organizationDepartment.Address = value;

            Assert.IsNotNull(organizationDepartment.Address);
            Assert.IsInstanceOfType(organizationDepartment.Address, typeof(AddressDto));
            Assert.AreEqual(value, organizationDepartment.Address);
        }
        public void OrganizationDepartmentDto_Property_Employees()
        {
            var organizationDepartment = new OrganizationDepartmentDto();
            var value = TestHelper.EmployeeDtos();

            organizationDepartment.Employees = value;

            Assert.IsNotNull(organizationDepartment.Employees);
            Assert.IsInstanceOfType(organizationDepartment.Employees, typeof(List <EmployeeDto>));
            Assert.AreEqual(value, organizationDepartment.Employees);
        }
        public void OrganizationDepartmentDto_Property_Branch()
        {
            var organizationDepartment = new OrganizationDepartmentDto();
            var value = TestHelper.OrganizationBranchDto();

            organizationDepartment.Branch = value;

            Assert.IsNotNull(organizationDepartment.Branch);
            Assert.IsInstanceOfType(organizationDepartment.Branch, typeof(OrganizationBranchDto));
            Assert.AreEqual(value, organizationDepartment.Branch);
        }
        public void OrganizationDepartmentDto_Property_Name()
        {
            var organizationDepartment = new OrganizationDepartmentDto();
            var value = "Test Department";

            organizationDepartment.Name = value;

            Assert.IsNotNull(organizationDepartment.Name);
            Assert.IsInstanceOfType(organizationDepartment.Name, typeof(string));
            Assert.AreEqual(value, organizationDepartment.Name);
        }
        public void OrganizationDepartmentDto_Property_IsDeleted()
        {
            var organizationDepartment = new OrganizationDepartmentDto();
            var value = false;

            organizationDepartment.IsDeleted = value;

            Assert.IsNotNull(organizationDepartment.IsDeleted);
            Assert.IsInstanceOfType(organizationDepartment.IsDeleted, typeof(bool));
            Assert.AreEqual(value, organizationDepartment.IsDeleted);
        }
        public void OrganizationDepartmentDto_Property_IsActive()
        {
            var organizationDepartment = new OrganizationDepartmentDto();
            var value = true;

            organizationDepartment.IsActive = value;

            Assert.IsNotNull(organizationDepartment.IsActive);
            Assert.IsInstanceOfType(organizationDepartment.IsActive, typeof(bool));
            Assert.AreEqual(value, organizationDepartment.IsActive);
        }
        public void OrganizationDepartmentDto_Property_ModifiedBy()
        {
            var organizationDepartment = new OrganizationDepartmentDto();
            var value = Core.Tests.TestHelper.UserDto();

            organizationDepartment.ModifiedBy = value;

            Assert.IsNotNull(organizationDepartment.ModifiedBy);
            Assert.IsInstanceOfType(organizationDepartment.ModifiedBy, typeof(UserDto));
            Assert.AreEqual(value, organizationDepartment.ModifiedBy);
        }
        public GenericServiceResponse <bool> DeleteOrganizationDepartment(OrganizationDepartmentDto organizationDepartment)
        {
            return(TryExecute <GenericServiceResponse <bool> >((response) =>
            {
                response.Result = Repository.Delete(organizationDepartment.AsEntity());

                if (!response.Result)
                {
                    var errorMessage = "'DeleteOrganizationDepartment' was unable to delete the given organizationDepartment record.";
                    response.Notifications.AddError(errorMessage);
                    Logger.Error(errorMessage);
                }
            }));
        }
Ejemplo n.º 11
0
        public void DeleteOrganizationDepartment_Service_Fail()
        {
            // Arrange
            organizationDepartmentService = new OrganizationDepartmentService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object);
            mockRepository.Setup(x => x.Delete(It.IsAny <OrganizationDepartment>())).Returns(false).Verifiable();

            // Act
            var organizationDepartment = new OrganizationDepartmentDto();
            var response = organizationDepartmentService.DeleteOrganizationDepartment(organizationDepartment);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsFalse(response.Result);
            Assert.IsTrue(response.Notifications.HasErrors());
            Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <bool>));
            mockRepository.Verify(x => x.Delete(It.IsAny <OrganizationDepartment>()), Times.Once);
        }
Ejemplo n.º 12
0
        public T Invoke(OrganizationDepartmentDto department)
        {
            return(Execute(() =>
            {
                var model = new GenericViewModel();

                var serviceResult = ServiceProvider.OrganizationDepartmentService.DeleteOrganizationDepartment(department);

                if (serviceResult == null || serviceResult.Notifications.HasErrors())
                {
                    var errorMessage = "Sorry, an unexpected error occurred.";
                    model.Notifications.AddError(errorMessage);
                }
                else
                {
                    model.Success = serviceResult.Result;
                }

                return OnComplete(model);
            }, this.GetType().Name));
        }
        public static OrganizationDepartment AsEntity(this OrganizationDepartmentDto organizationDepartmentDto)
        {
            if (organizationDepartmentDto == null)
            {
                return(null);
            }

            return(new OrganizationDepartment
            {
                ID = organizationDepartmentDto.Id,
                Name = organizationDepartmentDto.Name,
                Organization = organizationDepartmentDto.Organization.AsEntity(),
                Branch = organizationDepartmentDto.Branch.AsEntity(),
                Employees = organizationDepartmentDto.Employees.AsEntity(),
                Address = organizationDepartmentDto.Address.AsEntity(),
                Created = organizationDepartmentDto.Created,
                CreatedBy = organizationDepartmentDto.CreatedBy.AsEntity(),
                Modified = organizationDepartmentDto.Modified,
                ModifiedBy = organizationDepartmentDto.ModifiedBy.AsEntity(),
                IsActive = organizationDepartmentDto.IsActive,
                IsDeleted = organizationDepartmentDto.IsDeleted
            });
        }
        public void OrganizationDepartmentDto_Property_Count()
        {
            var organizationDepartment = new OrganizationDepartmentDto();

            Assert.AreEqual(12, organizationDepartment.GetType().GetProperties().Count());
        }