public async Task OnPostAsync_EditAnAssignment_ShouldSaveNewAssignmentName() { // Arrange var pageModel = new EditModel(MockAppDbContext.Object) { Assignment = ApplicationDbContext.GetSeedingAssignments().First(x => x.Id == 1) }; pageModel.Assignment.Name = "New Assignment Name"; pageModel.ApplicationModes = await pageModel.GetApplicationModes(1); pageModel.CoverageTypeOptions = await pageModel.GetCoverageTypeOptions(1); // Act await pageModel.OnPostAsync(1); // Assert Assert.Equal(pageModel.Assignment.Name, (await MockAppDbContext.Object.GetAssignmentById(1)).Name); }
public async Task OnPostAsync_EditAnAssignment_ShouldUpdateCoverageTypesToAllNotChecked() { // Arrange var pageModel = new EditModel(MockAppDbContext.Object) { Assignment = ApplicationDbContext.GetSeedingAssignments().First(x => x.Id == 1), }; pageModel.ApplicationModes = await pageModel.GetApplicationModes(1); pageModel.CoverageTypeOptions = await pageModel.GetCoverageTypeOptions(1); pageModel.CoverageTypeOptions.ToList().ForEach(type => type.IsChecked = false); // Act await pageModel.OnPostAsync(1); // Assert var updatedAssignment = await MockAppDbContext.Object.GetAssignmentById(1); updatedAssignment.AssignmentCoverageTypeOptions.ToList().ForEach(type => Assert.False(type.IsChecked)); }