Ejemplo n.º 1
0
        public void Test_User_LogIn_Successful()
        {
            sut.RegisterUser(testUser.FirstName, testUser.LastName, testUser.Email, testUser.UserName, testUser.Password);
            Assert.False(testRepository.FindUserByUserName(testUser.UserName).IsLoggedIn);
            sut.LogIn(testUser.UserName, testUser.Password);

            Assert.True(testRepository.FindUserByUserName(testUser.UserName).IsLoggedIn);
        }
Ejemplo n.º 2
0
        public void EqualWords_CountAnswerShouldBeIncremented()
        {
            InMemoryUserRepository userRepository = new InMemoryUserRepository();
            UserService            userService    = new UserService(userRepository);

            userService.RegisterUser("Test6");

            ExamineService examineService = new ExamineService(userService.LogIn("Test6"), new InMemoryWordRepository());
            var            twoWords       = examineService.GetTwoWords();

            twoWords[1].WordInEnglish = twoWords[0].WordInEnglish;
            Guid guidWord = twoWords[0].WordId;

            examineService.Check(true, twoWords);
            Assert.IsTrue(userRepository.LoadUser(userService.LogIn("Test6").Id).WordsListForUser._wordsInList[guidWord].CountOfTrueAnswers == 1);
        }
Ejemplo n.º 3
0
        public void UnexaminedWords_CountWordListShouldBeEqualFive()
        {
            InMemoryUserRepository userRepository = new InMemoryUserRepository();
            UserService            userService    = new UserService(userRepository);

            userService.RegisterUser("Test8");
            ViewerService viewerService       = new ViewerService(userService.LogIn("Test8"), new InMemoryWordRepository());
            var           wordsListUnexamined = viewerService.ViewUnexaminedWords();

            Assert.IsTrue(wordsListUnexamined.Count == 5);
        }
Ejemplo n.º 4
0
        public void EqualWords_CheckShouldBeTrue()
        {
            InMemoryUserRepository userRepository = new InMemoryUserRepository();
            UserService            userService    = new UserService(userRepository);

            userService.RegisterUser("Test4");

            ExamineService examineService = new ExamineService(userService.LogIn("Test4"), new InMemoryWordRepository());
            var            twoWords       = examineService.GetTwoWords();

            twoWords[1].WordInEnglish = twoWords[0].WordInEnglish;
            Assert.IsTrue(examineService.Check(true, twoWords));
        }
Ejemplo n.º 5
0
        public void UserRegister_UserRepositorySave()
        {
            TrainerService trainerService = new TrainerService();

            InMemoryUserRepository userRepositoryFirst = new InMemoryUserRepository();
            UserService            userServiceFirst    = new UserService(userRepositoryFirst);

            userServiceFirst.RegisterUser("Test3");
            trainerService.SaveMemoryUserRepository(userRepositoryFirst);

            InMemoryUserRepository userRepositorySecound = new InMemoryUserRepository();
            UserService            userServiceSecound    = new UserService(userRepositorySecound);

            Assert.AreNotEqual(userServiceSecound.LogIn("Test3"), null);
        }
Ejemplo n.º 6
0
        public void NotEqualWords_CheckShouldBeTrue()
        {
            InMemoryUserRepository userRepository = new InMemoryUserRepository();
            UserService            userService    = new UserService(userRepository);

            userService.RegisterUser("Test5");

            ExamineService examineService = new ExamineService(userService.LogIn("Test5"), new InMemoryWordRepository());
            //IList<Word> twoWords = new List<Word>(2);
            var twoWords = examineService.GetTwoWords();

            while (twoWords[0].WordInEnglish == twoWords[1].WordInEnglish)
            {
                twoWords = examineService.GetTwoWords();
            }
            twoWords[1].WordInEnglish = "1";
            Assert.IsTrue(examineService.Check(false, twoWords));
        }
Ejemplo n.º 7
0
        public void AllWorldsTrue_ShouldBeExeption()
        {
            InMemoryUserRepository userRepository = new InMemoryUserRepository();
            UserService            userService    = new UserService(userRepository);

            userService.RegisterUser("Test6");

            ExamineService examineService = new ExamineService(userService.LogIn("Test6"), new InMemoryWordRepository());
            var            twoWords       = examineService.GetTwoWords();

            for (var wordCount = 0; wordCount < 5; wordCount++)
            {
                for (var count = 0; count < 3; count++)
                {
                    twoWords[1].WordInEnglish = twoWords[0].WordInEnglish;
                    Guid guidWord = twoWords[0].WordId;
                    examineService.Check(true, twoWords);
                }
                twoWords = examineService.GetTwoWords();
            }
            twoWords = examineService.GetTwoWords();
        }