public void OrganizationBranchDto_Extension_AsEntity_Null() { OrganizationBranchDto organizationBranch = null; var result = organizationBranch.AsEntity(); Assert.IsNull(result); Assert.AreEqual(null, result); }
public void OrganizationBranchDto_Property_CreatedBy() { var organizationBranch = new OrganizationBranchDto(); var value = Core.Tests.TestHelper.UserDto(); organizationBranch.CreatedBy = value; Assert.IsNotNull(organizationBranch.CreatedBy); Assert.IsInstanceOfType(organizationBranch.CreatedBy, typeof(UserDto)); Assert.AreEqual(value, organizationBranch.CreatedBy); }
public void OrganizationBranchDto_Property_Created() { var organizationBranch = new OrganizationBranchDto(); var value = DateTime.Now; organizationBranch.Created = value; Assert.IsNotNull(organizationBranch.Created); Assert.IsInstanceOfType(organizationBranch.Created, typeof(DateTime)); Assert.AreEqual(value, organizationBranch.Created); }
public void OrganizationBranchDto_Property_Address() { var organizationBranch = new OrganizationBranchDto(); var value = Core.Tests.TestHelper.AddressDto(); organizationBranch.Address = value; Assert.IsNotNull(organizationBranch.Address); Assert.IsInstanceOfType(organizationBranch.Address, typeof(AddressDto)); Assert.AreEqual(value, organizationBranch.Address); }
public void OrganizationBranchDto_Property_Departments() { var organizationBranch = new OrganizationBranchDto(); var value = TestHelper.OrganizationDepartmentDtos(); organizationBranch.Departments = value; Assert.IsNotNull(organizationBranch.Departments); Assert.IsInstanceOfType(organizationBranch.Departments, typeof(List <OrganizationDepartmentDto>)); Assert.AreEqual(value, organizationBranch.Departments); }
public void OrganizationBranchDto_Property_Organization() { var organizationBranch = new OrganizationBranchDto(); var value = TestHelper.OrganizationDto(); organizationBranch.Organization = value; Assert.IsNotNull(organizationBranch.Organization); Assert.IsInstanceOfType(organizationBranch.Organization, typeof(OrganizationDto)); Assert.AreEqual(value, organizationBranch.Organization); }
public void OrganizationBranchDto_Property_Name() { var organizationBranch = new OrganizationBranchDto(); var value = "Test Branch"; organizationBranch.Name = value; Assert.IsNotNull(organizationBranch.Name); Assert.IsInstanceOfType(organizationBranch.Name, typeof(string)); Assert.AreEqual(value, organizationBranch.Name); }
public void Order_Property_IsDeleted() { var organizationBranch = new OrganizationBranchDto(); var value = false; organizationBranch.IsDeleted = value; Assert.IsNotNull(organizationBranch.IsDeleted); Assert.IsInstanceOfType(organizationBranch.IsDeleted, typeof(bool)); Assert.AreEqual(value, organizationBranch.IsDeleted); }
public GenericServiceResponse <bool> DeleteOrganizationBranch(OrganizationBranchDto organizationBranch) { return(TryExecute <GenericServiceResponse <bool> >((response) => { response.Result = Repository.Delete(organizationBranch.AsEntity()); if (!response.Result) { var errorMessage = "'DeleteOrganizationBranch' was unable to delete the given organizationBranch record."; response.Notifications.AddError(errorMessage); Logger.Error(errorMessage); } })); }
public void DeleteOrganizationBranch_Service_Fail() { // Arrange organizationBranchService = new OrganizationBranchService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object); mockRepository.Setup(x => x.Delete(It.IsAny <OrganizationBranch>())).Returns(false).Verifiable(); // Act var organizationBranch = new OrganizationBranchDto(); var response = organizationBranchService.DeleteOrganizationBranch(organizationBranch); // 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 <OrganizationBranch>()), Times.Once); }
public static OrganizationBranch AsEntity(this OrganizationBranchDto organizationBranchDto) { if (organizationBranchDto == null) { return(null); } return(new OrganizationBranch { ID = organizationBranchDto.Id, Name = organizationBranchDto.Name, Organization = organizationBranchDto.Organization.AsEntity(), Departments = organizationBranchDto.Departments.AsEntity(), Address = organizationBranchDto.Address.AsEntity(), Created = organizationBranchDto.Created, CreatedBy = organizationBranchDto.CreatedBy.AsEntity(), Modified = organizationBranchDto.Modified, ModifiedBy = organizationBranchDto.ModifiedBy.AsEntity(), IsDeleted = organizationBranchDto.IsDeleted }); }
public T Invoke(OrganizationBranchDto branch) { return(Execute(() => { var model = new GenericViewModel(); var serviceResult = ServiceProvider.OrganizationBranchService.DeleteOrganizationBranch(branch); 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 void OrganizationBranchDto_Property_Count() { var organizationBranch = new OrganizationBranchDto(); Assert.AreEqual(10, organizationBranch.GetType().GetProperties().Count()); }