public async void TestSignUpPageWithInvalidModelState() { using (var context = new UserDbContext(MockRSVPUserDb.TestRSVPDbContextOptions())) { MockEmailSender EmailSender = new MockEmailSender(); SignupModel sum = new SignupModel(context, EmailSender) { Name = "Test Name", Email = "fake@email", IsVeteran = true }; //Checking DB is actually empty var result = await context.Users.ToListAsync(); Assert.Empty(result); MockValidation.CheckValidation(sum); var page = sum.OnPost().Result; Assert.IsType <PageResult>(page); } }
public async void TestSignUpPageWithValidModelState() { using (var context = new UserDbContext(MockRSVPUserDb.TestRSVPDbContextOptions())) { MockEmailSender EmailSender = new MockEmailSender(); SignupModel sum = new SignupModel(context, EmailSender) { 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(sum); var page = sum.OnPost().Result; RedirectToPageResult check = (RedirectToPageResult)page; result = await context.Users.ToListAsync(); Assert.Single(result); Assert.Equal("/", check.PageName); } }