SearchGroups() public method

Vrátí skupiny ve kterých se v názvech objevuje daný řetězec
public SearchGroups ( string str ) : IQueryable
str string Řetězec pomocí kterého hledáme
return IQueryable
コード例 #1
0
ファイル: GroupServiceTest.cs プロジェクト: janmarek/Felbook
        public void SearchGroupsTest()
        {
            FelBookDBEntities DBEntities = new FelBookDBEntities();
            IWallService wallService = null;
            GroupService target = new GroupService(DBEntities, wallService);

            User user = User.CreateUser(0, "group", "creator", DateTime.Now,
                "mail", "groupCreator", "1234");
            DBEntities.UserSet.AddObject(user);

            Group group1 = Group.CreateGroup(0, "foo", "description");
            user.CreatedGroups.Add(group1);
            user.AdminedGroups.Add(group1);
            user.JoinedGroups.Add(group1);
            DBEntities.GroupSet.AddObject(group1);

            Group group2 = Group.CreateGroup(0, "foo2", "description");
            user.CreatedGroups.Add(group2);
            user.AdminedGroups.Add(group2);
            user.JoinedGroups.Add(group2);
            DBEntities.GroupSet.AddObject(group2);

            Group group3 = Group.CreateGroup(0, "moo", "description");
            user.CreatedGroups.Add(group3);
            user.AdminedGroups.Add(group3);
            user.JoinedGroups.Add(group3);
            DBEntities.GroupSet.AddObject(group3);

            DBEntities.SaveChanges();

            List<Group> actual = target.SearchGroups("2").ToList();
            Assert.IsFalse(actual.Contains(group1));
            Assert.IsTrue(actual.Contains(group2));
            Assert.IsFalse(actual.Contains(group3));

            actual = target.SearchGroups("foo").ToList();
            Assert.IsTrue(actual.Contains(group1));
            Assert.IsTrue(actual.Contains(group2));
            Assert.IsFalse(actual.Contains(group3));

            actual = target.SearchGroups("moo").ToList();
            Assert.IsFalse(actual.Contains(group1));
            Assert.IsFalse(actual.Contains(group2));
            Assert.IsTrue(actual.Contains(group3));

            actual = target.SearchGroups("abcdef").ToList();
            Assert.IsFalse(actual.Contains(group1));
            Assert.IsFalse(actual.Contains(group2));
            Assert.IsFalse(actual.Contains(group3));

            actual = target.SearchGroups("oo").ToList();
            Assert.IsTrue(actual.Contains(group1));
            Assert.IsTrue(actual.Contains(group2));
            Assert.IsTrue(actual.Contains(group3));

            DBEntities.GroupSet.DeleteObject(group1);
            DBEntities.GroupSet.DeleteObject(group2);
            DBEntities.GroupSet.DeleteObject(group3);
            DBEntities.UserSet.DeleteObject(user);
            DBEntities.SaveChanges();
        }