Ejemplo n.º 1
0
        public void Access_UserChangePassword_Check_ModelStateIsValid()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserChangePassword_Check_ModelStateIsValid")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            IUserRepository userRepository = new UserRepository(_context);
            var             testMapper     = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperConfig());
            });
            var mapper     = testMapper.CreateMapper();
            var controller = new UserController(userRepository, mapper);

            controller.ModelState.AddModelError("error", "some error");
            var view = controller.ChangePassword(model) as ViewResult;

            Assert.Equal("Change password", view.ViewData["Title"]);
            Assert.Equal("ChangePassword", view.ViewData["Action"]);
            Assert.Equal("User", view.ViewData["Controller"]);
        }
Ejemplo n.º 2
0
        public void Access_TestCreated_Check_db()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestCreated_Check_db")
                           .Options;

            using var _context = new TestMakerContext(options);
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);
            var             actionResult   = controller.Create(testData[0]);

            Assert.Equal(testData[0].TestId, _context.Tests.FirstOrDefault().TestId);
            Assert.Equal(testData[0].Title, _context.Tests.FirstOrDefault().Title);
            Assert.Equal(testData[0].CreatedTime, _context.Tests.FirstOrDefault().CreatedTime);
            Assert.Equal(testData[0].UpdatedTime, _context.Tests.FirstOrDefault().UpdatedTime);
            Assert.Equal(testData[0].UserId, _context.Tests.FirstOrDefault().UserId);
            Assert.Equal(testData[0].Questions[0].QuestionText, _context.Tests.FirstOrDefault().Questions[0].QuestionText);
            Assert.Equal(testData[0].Questions[0].TestId, _context.Tests.FirstOrDefault().Questions[0].TestId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceId, _context.Tests.FirstOrDefault().Questions[0].Choices[0].ChoiceId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceText, _context.Tests.FirstOrDefault().Questions[0].Choices[0].ChoiceText);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsAnswer, _context.Tests.FirstOrDefault().Questions[0].Choices[0].IsAnswer);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsUsersAnswerCheck, _context.Tests.FirstOrDefault().Questions[0].Choices[0].IsUsersAnswerCheck);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsUsersAnswerRadio, _context.Tests.FirstOrDefault().Questions[0].Choices[0].IsUsersAnswerRadio);
            Assert.Equal(testData[0].Questions[0].Choices[0].QuestionId, _context.Tests.FirstOrDefault().Questions[0].Choices[0].QuestionId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceText, _context.Tests.FirstOrDefault().Questions[0].Choices[0].ChoiceText);
            Assert.Equal(testData[0].Questions[0].Choices[0].QuestionId, _context.Choices.FirstOrDefault().QuestionId);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsAnswer, _context.Choices.FirstOrDefault().IsAnswer);
        }
Ejemplo n.º 3
0
        public void Access_TestEdited_Check_GivenInvalidModel()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestEdited_Check_GivenInvalidModel")
                           .Options;

            using var _context = new TestMakerContext(options);
            _context.Tests.Add(testData[0]);
            foreach (var q in testData[0].Questions)
            {
                _context.Questions.Add(q);
            }
            foreach (var c in testData[0].Questions[0].Choices)
            {
                _context.Choices.Add(c);
            }
            _context.SaveChanges();
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);

            controller.ModelState.AddModelError("error", "some error");
            var view = controller.Edit(1, testData[0]) as ViewResult;

            Assert.Null(view.ViewName);
        }
Ejemplo n.º 4
0
        public void Access_homeIndex_check_viewData()
        {
            var viewModel = HomeViewModelTestData.HomeIndexViewModelData();
            var options   = new DbContextOptionsBuilder <TestMakerContext>()
                            .UseInMemoryDatabase(databaseName: "Access_homeIndex_check_viewData")
                            .Options;

            using var _context = new TestMakerContext(options);
            foreach (var t in viewModel.Tests)
            {
                _context.Tests.Add(t);
            }
            foreach (var u in viewModel.Users)
            {
                _context.Users.Add(u);
            }
            _context.SaveChanges();
            IHomeRepository homeRepository = new HomeRepository(_context);
            var             controller     = new HomeController(homeRepository);
            var             view           = controller.Index() as ViewResult;

            Assert.Equal("Home Page", view.ViewData["Title"]);
            Assert.Equal("Index", view.ViewData["Action"]);
            Assert.Equal("Home", view.ViewData["Controller"]);
        }
Ejemplo n.º 5
0
        public void Access_TestDetails_check_viewData()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestDetails_check_viewData")
                           .Options;

            using var _context = new TestMakerContext(options);
            _context.Tests.Add(testData[0]);
            foreach (var q in testData[0].Questions)
            {
                _context.Questions.Add(q);
            }
            foreach (var c in testData[0].Questions[0].Choices)
            {
                _context.Choices.Add(c);
            }
            _context.SaveChanges();
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);
            var             view           = controller.Details(1) as ViewResult;

            Assert.Equal("Details", view.ViewData["Title"]);
            Assert.Equal("Details", view.ViewData["Action"]);
            Assert.Equal("Test", view.ViewData["Controller"]);
        }
Ejemplo n.º 6
0
        public void Access_UserIndex_db()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserIndex_db")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            Assert.Equal(model.LoginId, _context.Users.FirstOrDefault().LoginId);
            Assert.Equal(model.UserName, _context.Users.FirstOrDefault().UserName);
        }
Ejemplo n.º 7
0
        public void Access_TestDetails_check_whenIdNull_BeNotFound()
        {
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_TestDetails_check_whenIdNull_BeNotFound")
                          .Options;

            using var _context = new TestMakerContext(options);
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);
            var             actionResult   = controller.Details(null);

            Assert.IsType <NotFoundResult>(actionResult);
        }
Ejemplo n.º 8
0
        public void Access_TestEdited_Check_WhenIdDifferentPostedData_BeNotFound()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestEdited_Check_WhenIdDifferentPostedData_BeNotFound")
                           .Options;

            using var _context = new TestMakerContext(options);
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);
            var             actionResult   = controller.Edit(999999, testData[0]);

            Assert.IsType <NotFoundResult>(actionResult);
        }
Ejemplo n.º 9
0
        public async Task Access_UserChangePassword_db()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserChangePassword_db")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            var user = await _context.Users.FindAsync(1);

            Assert.Equal(model.LoginId, user.LoginId);
            Assert.Equal(model.Password, user.Password);
        }
Ejemplo n.º 10
0
        public void Access_TestIndex_check_viewData()
        {
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_TestIndex_check_viewData")
                          .Options;

            using var _context = new TestMakerContext(options);
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);
            var             view           = controller.Index(1) as ViewResult;

            Assert.Equal("Index", view.ViewData["Title"]);
            Assert.Equal("Index", view.ViewData["Action"]);
            Assert.Equal("Test", view.ViewData["Controller"]);
        }
Ejemplo n.º 11
0
        public void Access_TestCreated_check_RedirectToActionResult()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestCreated_check_viewData")
                           .Options;

            using var _context = new TestMakerContext(options);
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);
            var             actionResult   = controller.Create(testData[0]) as RedirectToActionResult;

            Assert.Equal("Index", actionResult.ActionName);
            Assert.Equal("Home", actionResult.ControllerName);
        }
Ejemplo n.º 12
0
        public void Access_TestDeleteConfirmed_Check_db()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestDeleteConfirmed_Check_db")
                           .Options;

            using var _context = new TestMakerContext(options);
            _context.Tests.Add(testData[0]);
            _context.SaveChanges();
            Assert.Equal(1, _context.Tests.Count());
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);

            controller.DeleteConfirmed(1);
            Assert.Equal(0, _context.Tests.Count());
        }
Ejemplo n.º 13
0
        public void Access_TestCreated_Check_GivenInvalidModel()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestCreated_Check_GivenInvalidModel")
                           .Options;

            using var _context = new TestMakerContext(options);
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);

            controller.ModelState.AddModelError("error", "some error");
            var view = controller.Create(testData[0]) as ViewResult;

            Assert.Equal(testData[0].Title, view.ViewData["Title"]);
            Assert.Equal(testData[0].Number, view.ViewData["Number"]);
        }
Ejemplo n.º 14
0
        public void Access_TestScore_Check_SingleCorrectResult()
        {
            var testData = TestModelData.TestDataForScoreSingleCorrectCheck();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestScore_Check_SingleCorrectResult1")
                           .Options;

            using var _context = new TestMakerContext(options);
            _context.Tests.Add(testData);
            _context.SaveChanges();
            ITestRepository testRepository = new TestRepository(_context);
            var             controller     = new TestController(testRepository);
            var             view           = controller.Score(1, testData) as ViewResult;

            Assert.Equal(1, view.ViewData["CorrectCount"]);
            Assert.Equal("Score", view.ViewData["Score"]);
            Assert.Equal("Details", view.ViewName);
        }
Ejemplo n.º 15
0
        public async Task Access_UserDetails_db()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserDetails_db")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            var user = await _context.Users.FirstOrDefaultAsync(m => m.UserId == 1);

            Assert.Equal(model.UserId, user.UserId);
            Assert.Equal(model.LoginId, user.LoginId);
            Assert.Equal(model.UserName, user.UserName);
            Assert.Equal(model.Icon, user.Icon);
            Assert.Equal(model.SelfIntroduction, user.SelfIntroduction);
        }
Ejemplo n.º 16
0
        public void Access_homeIndex_db()
        {
            var viewModel = HomeViewModelTestData.HomeIndexViewModelData();
            var options   = new DbContextOptionsBuilder <TestMakerContext>()
                            .UseInMemoryDatabase(databaseName: "Access_homeIndex_db")
                            .Options;

            using var _context = new TestMakerContext(options);
            foreach (var t in viewModel.Tests)
            {
                _context.Tests.Add(t);
            }
            foreach (var u in viewModel.Users)
            {
                _context.Users.Add(u);
            }
            _context.SaveChanges();
            IHomeRepository homeRepository = new HomeRepository(_context);
            var             homeInfoTest   = homeRepository.GetAll();

            Assert.Equal(viewModel.Tests[0].TestId, homeInfoTest.Tests[0].TestId);
            Assert.Equal(viewModel.Tests[0].Title, homeInfoTest.Tests[0].Title);
            Assert.Equal(viewModel.Tests[0].CreatedTime, homeInfoTest.Tests[0].CreatedTime);
            Assert.Equal(viewModel.Tests[0].UpdatedTime, homeInfoTest.Tests[0].UpdatedTime);
            Assert.Equal(viewModel.Tests[0].UserId, homeInfoTest.Tests[0].UserId);
            Assert.Equal(viewModel.Tests[0].Questions[0].QuestionText, homeInfoTest.Tests[0].Questions[0].QuestionText);
            Assert.Equal(viewModel.Tests[0].Questions[0].TestId, homeInfoTest.Tests[0].Questions[0].TestId);
            Assert.Equal(viewModel.Tests[0].Questions[0].Choices[0].ChoiceId, homeInfoTest.Tests[0].Questions[0].Choices[0].ChoiceId);
            Assert.Equal(viewModel.Tests[0].Questions[0].Choices[0].ChoiceText, homeInfoTest.Tests[0].Questions[0].Choices[0].ChoiceText);
            Assert.Equal(viewModel.Tests[0].Questions[0].Choices[0].IsAnswer, homeInfoTest.Tests[0].Questions[0].Choices[0].IsAnswer);
            Assert.Equal(viewModel.Tests[0].Questions[0].Choices[0].IsUsersAnswerCheck, homeInfoTest.Tests[0].Questions[0].Choices[0].IsUsersAnswerCheck);
            Assert.Equal(viewModel.Tests[0].Questions[0].Choices[0].IsUsersAnswerRadio, homeInfoTest.Tests[0].Questions[0].Choices[0].IsUsersAnswerRadio);
            Assert.Equal(viewModel.Tests[0].Questions[0].Choices[0].QuestionId, homeInfoTest.Tests[0].Questions[0].Choices[0].QuestionId);
            Assert.Equal(viewModel.Tests[0].Questions[0].Choices[0].ChoiceText, homeInfoTest.Tests[0].Questions[0].Choices[0].ChoiceText);
            Assert.Equal(viewModel.Tests[0].Questions[0].Choices[0].ChoiceText, homeInfoTest.Tests[0].Questions[0].Choices[0].ChoiceText);
            Assert.Equal(viewModel.Users[0].LoginId, homeInfoTest.Users[0].LoginId);
            Assert.Equal(viewModel.Users[0].UserName, homeInfoTest.Users[0].UserName);
            Assert.Equal(viewModel.Users[0].Password, homeInfoTest.Users[0].Password);
            Assert.Equal(viewModel.Users[0].Salt, homeInfoTest.Users[0].Salt);
            Assert.Equal(viewModel.Users[0].SelfIntroduction, homeInfoTest.Users[0].SelfIntroduction);
            Assert.Equal(viewModel.Users[0].Icon, homeInfoTest.Users[0].Icon);
        }
Ejemplo n.º 17
0
        public void Access_UserEdit_db()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserEdit_db")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            var user = _context.Users.Find(1);

            Assert.Equal(model.UserId, user.UserId);
            Assert.Equal(model.LoginId, user.LoginId);
            Assert.Equal(model.UserName, user.UserName);
            Assert.Equal(model.Password, user.Password);
            Assert.Equal(model.Salt, user.Salt);
            Assert.Equal(model.SelfIntroduction, user.SelfIntroduction);
            Assert.Equal(model.Icon, user.Icon);
        }
Ejemplo n.º 18
0
        public void Access_UserDetails_check_whenIdNull_BeNotFound()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserDetails_check_whenIdNull_BeNotFound")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            IUserRepository userRepository = new UserRepository(_context);
            var             testMapper     = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperConfig());
            });
            var mapper       = testMapper.CreateMapper();
            var controller   = new UserController(userRepository, mapper);
            var actionResult = controller.Details(null);

            Assert.IsType <NotFoundResult>(actionResult);
        }
Ejemplo n.º 19
0
        public void Access_UserDeleteConfirmed_Check_db()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserDeleteConfirmed_Check_db")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            Assert.Equal(1, _context.Users.Count());
            IUserRepository userRepository = new UserRepository(_context);
            var             testMapper     = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperConfig());
            });
            var mapper     = testMapper.CreateMapper();
            var controller = new UserController(userRepository, mapper);

            controller.DeleteConfirmed(1);
            Assert.Equal(0, _context.Users.Count());
        }
Ejemplo n.º 20
0
        public void Access_UserDeleteConfirmed_check_RedirectToActionResult()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserDeleteConfirmed_check_RedirectToActionResult")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            IUserRepository userRepository = new UserRepository(_context);
            var             testMapper     = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperConfig());
            });
            var mapper       = testMapper.CreateMapper();
            var controller   = new UserController(userRepository, mapper);
            var actionResult = controller.DeleteConfirmed(1) as RedirectToActionResult;

            Assert.Equal("Index", actionResult.ActionName);
            Assert.Equal("Home", actionResult.ControllerName);
        }
Ejemplo n.º 21
0
        public void Access_TestDetails_db()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestDetails_db")
                           .Options;

            using var _context = new TestMakerContext(options);
            _context.Tests.Add(testData[0]);
            foreach (var q in testData[0].Questions)
            {
                _context.Questions.Add(q);
            }
            foreach (var c in testData[0].Questions[0].Choices)
            {
                _context.Choices.Add(c);
            }
            _context.SaveChanges();
            ITestRepository testRepository = new TestRepository(_context);
            var             testInfoTest   = testRepository.GetContent(o => o.TestId == 1);

            Assert.Equal(testData[0].TestId, testInfoTest.TestId);
            Assert.Equal(testData[0].Title, testInfoTest.Title);
            Assert.Equal(testData[0].CreatedTime, testInfoTest.CreatedTime);
            Assert.Equal(testData[0].UpdatedTime, testInfoTest.UpdatedTime);
            Assert.Equal(testData[0].UserId, testInfoTest.UserId);
            Assert.Equal(testData[0].Questions[0].QuestionText, testInfoTest.Questions[0].QuestionText);
            Assert.Equal(testData[0].Questions[0].TestId, testInfoTest.Questions[0].TestId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceId, testInfoTest.Questions[0].Choices[0].ChoiceId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceText, testInfoTest.Questions[0].Choices[0].ChoiceText);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsAnswer, testInfoTest.Questions[0].Choices[0].IsAnswer);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsUsersAnswerCheck, testInfoTest.Questions[0].Choices[0].IsUsersAnswerCheck);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsUsersAnswerRadio, testInfoTest.Questions[0].Choices[0].IsUsersAnswerRadio);
            Assert.Equal(testData[0].Questions[0].Choices[0].QuestionId, testInfoTest.Questions[0].Choices[0].QuestionId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceText, testInfoTest.Questions[0].Choices[0].ChoiceText);
            Assert.Equal(testData[0].Questions[0].Choices[0].QuestionId, testInfoTest.Questions[0].Choices[0].QuestionId);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsAnswer, testInfoTest.Questions[0].Choices[0].IsAnswer);
        }
Ejemplo n.º 22
0
        public void Access_TestIndex_db()
        {
            var testData = TestModelData.TestData();
            var options  = new DbContextOptionsBuilder <TestMakerContext>()
                           .UseInMemoryDatabase(databaseName: "Access_TestIndex_db")
                           .Options;

            using var _context = new TestMakerContext(options);
            foreach (var t in testData)
            {
                _context.Tests.Add(t);
            }
            _context.Users.Add(testData[0].User);
            _context.SaveChanges();
            ITestRepository testRepository = new TestRepository(_context);
            var             testInfoTest   = testRepository.GetAll(1);

            Assert.Equal(testData[0].TestId, testInfoTest.FirstOrDefault().TestId);
            Assert.Equal(testData[0].Title, testInfoTest.FirstOrDefault().Title);
            Assert.Equal(testData[0].CreatedTime, testInfoTest.FirstOrDefault().CreatedTime);
            Assert.Equal(testData[0].UpdatedTime, testInfoTest.FirstOrDefault().UpdatedTime);
            Assert.Equal(testData[0].UserId, testInfoTest.FirstOrDefault().UserId);
            Assert.Equal(testData[0].Questions[0].QuestionText, testInfoTest.FirstOrDefault().Questions[0].QuestionText);
            Assert.Equal(testData[0].Questions[0].TestId, testInfoTest.FirstOrDefault().Questions[0].TestId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceId, testInfoTest.FirstOrDefault().Questions[0].Choices[0].ChoiceId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceText, testInfoTest.FirstOrDefault().Questions[0].Choices[0].ChoiceText);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsAnswer, testInfoTest.FirstOrDefault().Questions[0].Choices[0].IsAnswer);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsUsersAnswerCheck, testInfoTest.FirstOrDefault().Questions[0].Choices[0].IsUsersAnswerCheck);
            Assert.Equal(testData[0].Questions[0].Choices[0].IsUsersAnswerRadio, testInfoTest.FirstOrDefault().Questions[0].Choices[0].IsUsersAnswerRadio);
            Assert.Equal(testData[0].Questions[0].Choices[0].QuestionId, testInfoTest.FirstOrDefault().Questions[0].Choices[0].QuestionId);
            Assert.Equal(testData[0].Questions[0].Choices[0].ChoiceText, testInfoTest.FirstOrDefault().Questions[0].Choices[0].ChoiceText);
            Assert.Equal(testData[0].User.LoginId, testInfoTest.FirstOrDefault().User.LoginId);
            Assert.Equal(testData[0].User.UserName, testInfoTest.FirstOrDefault().User.UserName);
            Assert.Equal(testData[0].User.Password, testInfoTest.FirstOrDefault().User.Password);
            Assert.Equal(testData[0].User.Salt, testInfoTest.FirstOrDefault().User.Salt);
            Assert.Equal(testData[0].User.SelfIntroduction, testInfoTest.FirstOrDefault().User.SelfIntroduction);
            Assert.Equal(testData[0].User.Icon, testInfoTest.FirstOrDefault().User.Icon);
        }
Ejemplo n.º 23
0
        public void Access_UserIndex_check_viewData()
        {
            var model   = UserModelTestData.UserModelData();
            var options = new DbContextOptionsBuilder <TestMakerContext>()
                          .UseInMemoryDatabase(databaseName: "Access_UserIndex_check_viewData")
                          .Options;

            using var _context = new TestMakerContext(options);
            _context.Users.Add(model);
            _context.SaveChanges();
            IUserRepository userRepository = new UserRepository(_context);
            var             testMapper     = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperConfig());
            });
            var mapper     = testMapper.CreateMapper();
            var controller = new UserController(userRepository, mapper);
            var view       = controller.Index() as ViewResult;

            Assert.Equal("Index", view.ViewData["Title"]);
            Assert.Equal("Index", view.ViewData["Action"]);
            Assert.Equal("User", view.ViewData["Controller"]);
        }
Ejemplo n.º 24
0
 public AccountRepository(TestMakerContext context)
 {
     _context = context;
 }
Ejemplo n.º 25
0
 public HomeRepository(TestMakerContext context)
 {
     _context = context;
 }
Ejemplo n.º 26
0
 public UserRepository(TestMakerContext context)
     : base(context)
 {
     _context = context;
 }
Ejemplo n.º 27
0
 public GenericRepository(TestMakerContext context)
 {
     _context = context;
 }