Exemplo n.º 1
0
 public async Task TestService_LoginUser_Success() {
     using (YuYanDBContext db = new YuYanDBContext())
     using (YuYanDBRepository repos = new YuYanDBRepository(db))
     {
         YuYanService svc = new YuYanService(repos);
         dtoUser newUser = new dtoUser() { Email = "*****@*****.**", Password = "******" };
         dtoUserProfile userObj = await svc.LoginUser(newUser);
         Assert.IsNotNull(userObj);
         Assert.AreEqual("*****@*****.**", userObj.Email);
     }
 }
Exemplo n.º 2
0
        public async Task TestGetGeoIP() {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                YuYanService svc = new YuYanService(repos);
                var controller = new ClientController(svc);

                var result = await controller.GetGeoIP("121.214.23.68");
                Assert.IsNotNull(result);
            }
        }
Exemplo n.º 3
0
        public async Task TestService_LogoutUser_Success() {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                YuYanService svc = new YuYanService(repos);

                bool isLogout = await svc.LogoutUser(new Guid("1A737355-2BF8-4CF6-AB28-A2694CD2A0D8"));

                Assert.AreEqual(true, isLogout);
            }
        }
Exemplo n.º 4
0
 public async Task TestService_LoginUser_Failed_NoUser()
 {
     using (YuYanDBContext db = new YuYanDBContext())
     using (YuYanDBRepository repos = new YuYanDBRepository(db))
     {
         YuYanService svc = new YuYanService(repos);
         dtoUser newUser = new dtoUser() { Email = "*****@*****.**", Password = "******" };
         dtoUserProfile userObj = await svc.LoginUser(newUser);
         Assert.IsNull(userObj);
     }
 }
Exemplo n.º 5
0
        public async Task TestRepo_FailedLogin_UnknownUser()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                dtoUser testuser = new dtoUser() { Email = "*****@*****.**", Password = "******" };

                tbUser userobj = await repos.LoginUser(testuser);
                Assert.IsNull(userobj); // is null means the user not existed in the database
            }
        }
Exemplo n.º 6
0
        public async Task TestRepo_SuccessLogin_User()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                dtoUser testuser = new dtoUser() { Email = "*****@*****.**", Password = "******" };

                tbUser userobj = await repos.LoginUser(testuser);
                Assert.IsNotNull(userobj);
                Assert.AreEqual("*****@*****.**", userobj.Email, true);
            }
        }
Exemplo n.º 7
0
        public async Task TestController_GetSurveyBySurveyId()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                YuYanService svc = new YuYanService(repos);
                var controller = new SurveyController(svc);

                var result = await controller.GetSurveyBySurveyId(92);
                Assert.IsNotNull(result);
            }
        }
Exemplo n.º 8
0
 public async Task TestService_LoginUser_Failed_WrongPassword()
 {
     using (YuYanDBContext db = new YuYanDBContext())
     using (YuYanDBRepository repos = new YuYanDBRepository(db))
     {
         YuYanService svc = new YuYanService(repos);
         dtoUser newUser = new dtoUser() { Email = "*****@*****.**", Password = "******" };
         dtoUserProfile userObj = await svc.LoginUser(newUser);
         Assert.IsNotNull(userObj);
         Assert.AreEqual(Guid.Empty, userObj.UserId);
     }
 }
Exemplo n.º 9
0
        public async Task TestController_CreateSurvey() {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                YuYanService svc = new YuYanService(repos);
                var controller = new SurveyController(svc);

                dtoSurvey testObj = new dtoSurvey();
                testObj.Title = "Make me happy";
                testObj.ShortDesc = "No short description";

                var result = await controller.CreateSurvey(testObj);
                Assert.IsNotNull(result);
            }
        }
Exemplo n.º 10
0
        public async Task TestController_CreateQuestion() { 
            using(YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db)) {
                YuYanService svc = new YuYanService(repos);
                var controller = new SurveyController(svc);

                dtoSurveyQuestion questionObj = new dtoSurveyQuestion();
                questionObj.Question = "Add from Test";
                questionObj.QuestionType = QuestionType.checkbox;
                //questionObj.SurveyId = 6;

                var result = await controller.CreateQuestion(6, questionObj);
                Assert.IsNotNull(result);
            }
        }
Exemplo n.º 11
0
        public async Task TestRepo_DeleteItem()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                dtoSurveyQuestionItem newItem = new dtoSurveyQuestionItem();

                await repos.DeleteItem(4);

            }
        }
Exemplo n.º 12
0
        public async Task TestRepo_UpdateItem()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                dtoSurveyQuestionItem newItem = new dtoSurveyQuestionItem();
                newItem.QuestionItemId = 7;
                newItem.ItemDescription = "The ddddd chdfdsfsdsfoice";

                var obj = await repos.UpdateItem(newItem);
                Assert.IsNotNull(obj);
            }
        }
Exemplo n.º 13
0
        public async Task TestRepo_CreateItem()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                dtoSurveyQuestionItem newItem = new dtoSurveyQuestionItem();
                newItem.QuestionId = 1;
                newItem.ItemDescription = "The third choice";

                var obj = await repos.CreateNewItem(newItem);
                Assert.IsNotNull(obj);
            }
        }
Exemplo n.º 14
0
        public async Task TestRepo_GetQuestionItemsByQuestionId()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {

                var obj = await repos.GetQuestionItemsByQuestionId(1);
                Assert.IsNotNull(obj);
            }
        }
Exemplo n.º 15
0
        public async Task TestRepo_GetSurveyBySurveyId()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {

                tbSurvey obj = await repos.GetSurveyBySurveyId(92);
                Assert.IsNotNull(obj);
                Assert.AreEqual("9292929292", obj.Title, true);
            }
        }
Exemplo n.º 16
0
 public async Task TestService_GetSurveyBySurveyId()
 {
     using (YuYanDBContext db = new YuYanDBContext())
     using (YuYanDBRepository repos = new YuYanDBRepository(db))
     {
         YuYanService svc = new YuYanService(repos);
         dtoSurvey obj = await svc.GetSurveyBySurveyId(1);
         Assert.IsNotNull(obj);
     }
 }
Exemplo n.º 17
0
        public async Task TestRepo_FailedLogin_WrongPasswordUser()
        {
            using (YuYanDBContext db = new YuYanDBContext())
            using (YuYanDBRepository repos = new YuYanDBRepository(db))
            {
                dtoUser testuser = new dtoUser() { Email = "*****@*****.**", Password = "******" };

                tbUser userobj = await repos.LoginUser(testuser);
                Assert.IsNotNull(userobj); // is new tbUser means the password not match
                Assert.AreEqual(Guid.Empty, userobj.UserId);
            }
        }
Exemplo n.º 18
0
 public async Task TestService_DeleteSurveyQuestion() {
     using (YuYanDBContext db = new YuYanDBContext())
     using (YuYanDBRepository repos = new YuYanDBRepository(db))
     {
         YuYanService svc = new YuYanService(repos);
         await svc.DeleteSurveyQuestion(1);
         
     }
 }