public async void TestAddUserPageTryingToAddUserWithInvalidModelState() { using (var context = new UserDbContext(MockRSVPUserDb.TestRSVPDbContextOptions())) { Add_UserModel aum = new Add_UserModel(context) { Name = "Test User", PhoneNumber = "0123456789" }; //Checking DB is actually empty var result = await context.Users.ToListAsync(); Assert.Empty(result); //Checking Validation of the Model MockValidation.CheckValidation(aum); var page = aum.OnPost().Result; Assert.IsType <PageResult>(page); } }
public async void TestAddUserPageAddingAUserWithValidModelState() { using (var context = new UserDbContext(MockRSVPUserDb.TestRSVPDbContextOptions())) { Add_UserModel aum = new Add_UserModel(context) { Agree = true, Name = "Test User", Email = "*****@*****.**", PhoneNumber = "0123456789", IsVeteran = true, PreferredTime = false, IsWashingtonResident = true, ChooseMaritalStatus = MaritalStatus.SingleAndNeverDivorced, SpouseName = "N/A", HasChildren = false, IsCurrentlyPregnant = false, MinorChildName = "N/A", ContRemBeneficiary = WhoToInheritEstate.OtherPerson, PersonToInherit = WhoToInheritEstate.OtherPerson, PersonalRep = WhoToInheritEstate.OtherPerson, }; //Checking DB is actually empty var result = await context.Users.ToListAsync(); Assert.Empty(result); MockValidation.CheckValidation(aum); var page = await aum.OnPost(); RedirectToPageResult check = (RedirectToPageResult)page; result = await context.Users.ToListAsync(); Assert.Single(result); Assert.Equal("/Dashboard", check.PageName); } }