Пример #1
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);
            }
        }
Пример #2
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
            }
        }
Пример #3
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);
     }
 }
Пример #4
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);
     }
 }
Пример #5
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);
            }
        }
Пример #6
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);
     }
 }
Пример #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);
            }
        }
Пример #8
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);
            }
        }
Пример #9
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);
            }
        }
Пример #10
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);
            }
        }
Пример #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);

            }
        }
Пример #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);
            }
        }
Пример #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);
            }
        }
Пример #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);
            }
        }
Пример #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);
            }
        }
Пример #16
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);
         
     }
 }
Пример #17
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);
     }
 }
Пример #18
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);
            }
        }
Пример #19
0
 public static YuYanDBContext Create()
 {
     var db = new YuYanDBContext();
     return db;
 }