Пример #1
0
            public void AddRole()
            {
                DiSetup.Tests();
                IUserService userService = DiHelper.GetService <IUserService>();

                userService.Clear();
                userService.CreateTestData();
                AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>();

                int rolecountBefore = authenticationService.GetRoles().Count();

                var result = authenticationService.AddRole(new Models.Role("SomeRole", null));

                int rolecountAfter = authenticationService.GetRoles().Count();

                Assert.IsNotNull(result);
                Assert.AreEqual(true, result);
                Assert.IsTrue(rolecountBefore + 1 == rolecountAfter);
            }
Пример #2
0
            public void AddRoleNegative()
            {
                DiSetup.Tests();
                IUserService userService = DiHelper.GetService <IUserService>();

                userService.Clear();
                userService.CreateTestData();
                AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>();
                var existingRole = authenticationService.GetRoles().ToList()[0];

                int rolecountBefore = authenticationService.GetRoles().Count();

                var result = authenticationService.AddRole(existingRole);  //try to add an existing role

                int rolecountAfter = authenticationService.GetRoles().Count();

                Assert.IsNotNull(result);
                Assert.AreEqual(false, result);
                Assert.IsTrue(rolecountBefore == rolecountAfter);
            }