Beispiel #1
0
        public void GetUserListTest()
        {
            var dbName  = Guid.NewGuid().ToString();
            var context = ConstruitContexto(dbName);

            context.TbUsers.Add(new Mudandaz_PhanorMesias.Models.TbUser()
            {
                UserId = 1, Login = "******", Name = "log1", Password = "******"
            });
            context.TbUsers.Add(new Mudandaz_PhanorMesias.Models.TbUser()
            {
                UserId = 2, Login = "******", Name = "log2", Password = "******"
            });
            context.TbUsers.Add(new Mudandaz_PhanorMesias.Models.TbUser()
            {
                UserId = 3, Login = "******", Name = "log3", Password = "******"
            });

            context.SaveChanges();

            var context2 = ConstruitContexto(dbName);

            var controller         = new UserAuthenticationController(context2);
            var resp               = controller.GetUserList();
            List <TbUserModel> lst = (List <TbUserModel>)resp;

            Assert.AreEqual(3, lst.Count);
        }
Beispiel #2
0
        public void GetModulesTest()
        {
            var dbName  = Guid.NewGuid().ToString();
            var context = ConstruitContexto(dbName);

            context.TbModules.Add(new Mudandaz_PhanorMesias.Models.TbModule()
            {
                ModuleId = 1, Module = "mod1", Description = "mod1", Image = "", Url = ""
            });
            context.TbModules.Add(new Mudandaz_PhanorMesias.Models.TbModule()
            {
                ModuleId = 2, Module = "mod2", Description = "mod2", Image = "", Url = ""
            });
            context.TbModules.Add(new Mudandaz_PhanorMesias.Models.TbModule()
            {
                ModuleId = 3, Module = "mod3", Description = "mod3", Image = "", Url = ""
            });
            context.TbModules.Add(new Mudandaz_PhanorMesias.Models.TbModule()
            {
                ModuleId = 4, Module = "mod4", Description = "mod4", Image = "", Url = ""
            });

            context.SaveChanges();

            var context2 = ConstruitContexto(dbName);

            var controller            = new UserAuthenticationController(context2);
            List <TbModuleModel> resp = controller.GetModules();

            Assert.AreEqual(4, resp.Count);
        }
Beispiel #3
0
        public void GetModulesByUserTest()
        {
            var dbName  = Guid.NewGuid().ToString();
            var context = ConstruitContexto(dbName);

            context.TbUsers.Add(new Mudandaz_PhanorMesias.Models.TbUser()
            {
                UserId = 1, Login = "******", Name = "log1", Password = "******"
            });
            context.TbModules.Add(new Mudandaz_PhanorMesias.Models.TbModule()
            {
                ModuleId = 1, Module = "mod1", Description = "mod1", Image = "", Url = ""
            });
            context.TbModules.Add(new Mudandaz_PhanorMesias.Models.TbModule()
            {
                ModuleId = 2, Module = "mod2", Description = "mod2", Image = "", Url = ""
            });
            context.TbModules.Add(new Mudandaz_PhanorMesias.Models.TbModule()
            {
                ModuleId = 3, Module = "mod3", Description = "mod3", Image = "", Url = ""
            });
            context.TbModules.Add(new Mudandaz_PhanorMesias.Models.TbModule()
            {
                ModuleId = 4, Module = "mod4", Description = "mod4", Image = "", Url = ""
            });

            context.TnUserAuthorizations.Add(new Mudandaz_PhanorMesias.Models.TnUserAuthorization()
            {
                UserAuthorizationId = 1, User = 1, Module = 1
            });
            context.TnUserAuthorizations.Add(new Mudandaz_PhanorMesias.Models.TnUserAuthorization()
            {
                UserAuthorizationId = 2, User = 1, Module = 2
            });
            context.TnUserAuthorizations.Add(new Mudandaz_PhanorMesias.Models.TnUserAuthorization()
            {
                UserAuthorizationId = 3, User = 1, Module = 3
            });

            context.SaveChanges();

            var context2 = ConstruitContexto(dbName);

            var controller           = new UserAuthenticationController(context2);
            var resp                 = controller.GetModulesByUser(1);
            List <TbModuleModel> lst = (List <TbModuleModel>)resp;

            Assert.AreEqual(3, lst.Count);
        }
Beispiel #4
0
        public void GetUserTest_FailAuthenticate()
        {
            var dbName  = Guid.NewGuid().ToString();
            var context = ConstruitContexto(dbName);

            context.TbUsers.Add(new Mudandaz_PhanorMesias.Models.TbUser()
            {
                UserId = 1, Login = "******", Name = "log1", Password = "******"
            });

            context.SaveChanges();

            var context2 = ConstruitContexto(dbName);

            var controller = new UserAuthenticationController(context2);
            var resp       = controller.GetUser("log1", "222");

            Assert.AreEqual(0, resp.UserId);
        }