Example #1
0
 public void TestDetailsPageOnGetWithoutIDValue()
 {
     using (var context = new UserDbContext(MockRSVPUserDb.TestRSVPDbContextOptions()))
     {
         DetailsModel         dm    = new DetailsModel(context);
         var                  page  = dm.OnGet(null);
         RedirectToPageResult check = (RedirectToPageResult)page;
         Assert.Equal("/Dashboard", check.PageName);
     }
 }
Example #2
0
        public void OnGet_populatesPostModel()
        {
            var post = new Post {
                Title = "Post 1"
            };

            var postData = new Mock <IPostData>();

            postData.Setup((x) => x.GetBySlug(It.IsAny <string>()))
            .Returns(() => post);

            var detailsModel = new DetailsModel(postData.Object);

            detailsModel.OnGet("post-1");

            Assert.IsAssignableFrom <Post>(detailsModel.Post);
            Assert.Equal("Post 1", detailsModel.Post.Title);
        }
Example #3
0
        public async void TestDetailsPageOnGetWithIDValueAndValidUser()
        {
            using (var context = new UserDbContext(MockRSVPUserDb.TestRSVPDbContextOptions()))
            {
                DetailsModel dm   = new DetailsModel(context);
                RSVPUser     user = new RSVPUser
                {
                    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);

                await context.Users.AddAsync(user);

                await context.SaveChangesAsync();

                var page = dm.OnGet(1);
                result = await context.Users.ToListAsync();

                Assert.Single(result);
                Assert.IsType <PageResult>(page);
            }
        }