public void FindByIdTest() { FelBookDBEntities DBEntities = new FelBookDBEntities(); IWallService wallService = null; GroupService target = new GroupService(DBEntities, wallService); Group actual; try { actual = target.FindById(-1); Assert.Fail(); } catch (InvalidOperationException) { } User user = User.CreateUser(0, "group", "creator", DateTime.Now, "mail", "groupCreator", "1234"); DBEntities.UserSet.AddObject(user); Group expected = Group.CreateGroup(0, "newGroup", "groupDescription"); user.CreatedGroups.Add(expected); user.AdminedGroups.Add(expected); user.JoinedGroups.Add(expected); DBEntities.GroupSet.AddObject(expected); DBEntities.SaveChanges(); actual = target.FindById(expected.Id); Assert.AreEqual(expected, actual); DBEntities.GroupSet.DeleteObject(expected); DBEntities.UserSet.DeleteObject(user); DBEntities.SaveChanges(); }