Exemple #1
0
        public void Get_Groups_Assigned_To_Section()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                UserGroupRepository repository = CreateRepository(provider);

                UserGroup user1 = UserGroupBuilder.CreateUserGroup(suffix: "1", allowedSections: new[] { "test1" });
                UserGroup user2 = UserGroupBuilder.CreateUserGroup(suffix: "2", allowedSections: new[] { "test2" });
                UserGroup user3 = UserGroupBuilder.CreateUserGroup(suffix: "3", allowedSections: new[] { "test1" });
                repository.Save(user1);
                repository.Save(user2);
                repository.Save(user3);
                scope.Complete();

                // Act
                IEnumerable <IUserGroup> groups = repository.GetGroupsAssignedToSection("test1");

                // Assert
                Assert.AreEqual(2, groups.Count());
                string[] names = groups.Select(x => x.Name).ToArray();
                Assert.IsTrue(names.Contains("Test Group1"));
                Assert.IsFalse(names.Contains("Test Group2"));
                Assert.IsTrue(names.Contains("Test Group3"));
            }
        }