public async Task TestUpdate() { var groupAppService = Substitute.For <IGroupAppService>(); var target = new GroupController( CreateMemoryCache(), CreateMapper(), Substitute.For <IDepartmentAppService>(), Substitute.For <IPositionAppService>(), groupAppService); target.ControllerContext = CreateMockContext(); groupAppService.UpdateAsync(Arg.Any <GroupInput>()) .ReturnsForAnyArgs(RemotingResult.Success()); var result = await target.Update(Guid.NewGuid(), new GroupEditVm()); result.Value.Should().NotBeNull(); result.Value.Status.Should().Be(0); groupAppService.UpdateAsync(Arg.Any <GroupInput>()) .ReturnsForAnyArgs(RemotingResult.Fail()); result = await target.Update(Guid.NewGuid(), new GroupEditVm()); result.Value.Status.Should().NotBe(0); groupAppService.UpdateAsync(Arg.Any <GroupInput>()) .ReturnsForAnyArgs(RemotingResult.Fail(FailedCodes.Group_NotCreatedBy)); result = await target.Update(Guid.NewGuid(), new GroupEditVm()); result.Value.Status.Should().Be(FailedCodes.Group_NotCreatedBy); }
public void Update_ForGroup_ReturnActionResult() { // Arrange InitializeHttpUpdate(); var controller = new GroupController(); var group = new Models.Group() { CustomerID = GroupId, UpdatedUserID = GroupId, FolderID = GroupId, GroupName = FolderName, MasterSupression = 0, CreatedUserID = GroupId, PublicFolder = 1, AllowUDFHistory = UdfHistory, IsSeedList = false }; // Act var result = controller.Update(group) as JsonResult; // Assert result.ShouldSatisfyAllConditions( () => result.ShouldNotBeNull(), () => result.Data.ShouldNotBeNull()); }
public void UpdateGroup() { var groupName = "UpdateExistingGroup"; var newGroup = CreateGroup(groupName); var groups = _groupController.Get(groupName); var matches = groups.Count(g => g.Name == groupName); Assert.Equal(1, matches); var updateGroup = new Group { Id = newGroup.Id, Name = "UpdateExistingGroupProof" }; _groupController.Update(updateGroup); var updatedGroup = _groupController.Get(newGroup.Id); Assert.Equal("UpdateExistingGroupProof", updatedGroup.Name); }
public void When_UpdateGroupName_Expect_GroupUpdate() { var errorMessage = string.Empty; var guid = Guid.NewGuid().ToString(); var newGroupCommand = new CreateGroupCommand() { Group = new Group() { Name = guid, CurrentCapacity = 100M } }; var actionResult = _groupController.Create(newGroupCommand); var createdGroup = ActionResultParser.ParseCreatedResult <Group>(actionResult, out errorMessage); CheckErrorMessage(errorMessage); if (createdGroup.Id == 0) { Assert.Fail(); } var newGuid = Guid.NewGuid().ToString(); var groupUpdateCommand = new UpdateGroupCommand() { Group = new Group() { Id = createdGroup.Id, CurrentCapacity = createdGroup.CurrentCapacity, Name = newGuid } }; actionResult = _groupController.Update(groupUpdateCommand); var updatedGroup = ActionResultParser.ParseOkObjectResult <Group>(actionResult, out errorMessage); CheckErrorMessage(errorMessage); Assert.AreEqual(newGuid, updatedGroup.Name); DeleteGroup(updatedGroup); }
public int? SaveGroup( int groupTypeId, string name, int? parentGroupId = null, bool isSystem = false, int? campusId = null, string description = null, bool isSecurityRole = false, bool isActive = true, int order = 0, string foreignId = null, int? groupId = null ) { Group group = null; GroupController controller = new GroupController( Service ); if ( groupId != null ) { group = controller.GetById( (int)groupId ); if ( groupId == null ) { return null; } } else { group = new Group(); } group.IsSystem = isSystem; group.ParentGroupId = parentGroupId; group.GroupTypeId = groupTypeId; group.CampusId = campusId; group.Name = name; group.Description = description; group.IsSecurityRole = isSecurityRole; group.IsActive = isActive; group.Order = order; group.ForeignId = foreignId; if ( groupId == null ) { group.CreatedByPersonAliasId = Service.LoggedInPerson.PrimaryAliasId; controller.Add( group ); } else { group.ModifiedByPersonAliasId = Service.LoggedInPerson.PrimaryAliasId; controller.Update( group ); } group = controller.GetByGuid( group.Guid ); return group.Id; }