public void AddDelegateGroup_sets_GroupDetails_correctly() { // Given var timeNow = DateTime.UtcNow; GivenCurrentTimeIs(timeNow); var groupDetails = new GroupDetails { CentreId = 101, GroupLabel = "Group name", GroupDescription = "Group description", AdminUserId = 1, CreatedDate = timeNow, LinkedToField = 1, SyncFieldChanges = true, AddNewRegistrants = true, PopulateExisting = true, }; const int returnId = 1; A.CallTo(() => groupsDataService.AddDelegateGroup(A <GroupDetails> ._)).Returns(returnId); // When var result = groupsService.AddDelegateGroup( groupDetails.CentreId, groupDetails.GroupLabel, groupDetails.GroupDescription, groupDetails.AdminUserId, groupDetails.LinkedToField, groupDetails.SyncFieldChanges, groupDetails.AddNewRegistrants, groupDetails.PopulateExisting ); // Then using (new AssertionScope()) { result.Should().Be(returnId); A.CallTo( () => groupsDataService.AddDelegateGroup( A <GroupDetails> .That.Matches( gd => gd.CentreId == groupDetails.CentreId && gd.GroupLabel == groupDetails.GroupLabel && gd.GroupDescription == groupDetails.GroupDescription && gd.AdminUserId == groupDetails.AdminUserId && gd.CreatedDate == groupDetails.CreatedDate && gd.LinkedToField == groupDetails.LinkedToField && gd.SyncFieldChanges == groupDetails.SyncFieldChanges && gd.AddNewRegistrants == groupDetails.AddNewRegistrants && gd.PopulateExisting == groupDetails.PopulateExisting ) ) ).MustHaveHappenedOnceExactly(); } }
public IActionResult AddDelegateGroup(AddDelegateGroupViewModel model) { if (!ModelState.IsValid) { return(View(model)); } groupsService.AddDelegateGroup( User.GetCentreId(), model.GroupName !, model.GroupDescription, User.GetAdminId() !.Value ); return(RedirectToAction("Index")); }