public void GivenASchool_WhenUpdate_ThenContextSetsModified()
        {
            var expected = new School { Id = 1 };

            Target.Update(expected);

            MockContext.AssertWasCalled(m => m.SetModified(expected));
        }
        public void GivenASchool_WhenDelete_ThenRemoveFromContext()
        {
            var item = new School { Id = 1 };

            Target.Remove(item);

            MockDbSet.AssertWasCalled(m => m.Remove(item));
        }
        public void GivenASchool_WhenAdd_ThenAddToContext()
        {
            var expected = new School { Id = 1 };

            Target.Add(expected);

            MockDbSet.AssertWasCalled(m => m.Add(expected));
        }
        public void GivenAnUnassociatedUserRoleAndSchool_WhenAddLink_ThenTheyAreAssociated()
        {
            UserRole userRole = new UserRole();
            School school = new School();

            Target.AddLink(userRole, school);

            CollectionAssert.Contains(userRole.Schools.ToList(), school);
            CollectionAssert.Contains(school.UserRoles.ToList(), userRole);
        }
        public void GivenAnAssociatedUserRoleAndSchool_WhenDeleteLink_ThenTheyAreNoLongerAssociated()
        {
            UserRole userRole = new UserRole();
            School school = new School { UserRoles = new List<UserRole> { userRole } };
            userRole.Schools.Add(school);

            Target.DeleteLink(userRole, school);

            CollectionAssert.DoesNotContain(userRole.Schools.ToList(), school);
            CollectionAssert.DoesNotContain(school.UserRoles.ToList(), userRole);
        }
 public void AddLink(UserRole userRole, School school)
 {
     if (userRole == null)
     {
         throw new ArgumentNullException("userRole");
     }
     if (school == null)
     {
         throw new ArgumentNullException("school");
     }
     userRole.Schools.Add(school);
     school.UserRoles.Add(userRole);
 }
        public void GivenNullUserRole_AndSchool_WhenDeleteLink_ThenThrowException()
        {
            School school = new School();

            Target.ExpectException<ArgumentNullException>(() => Target.DeleteLink(null, school));
        }
 public void Update(School item)
 {
     Context.SetModified(item);
 }
 public void Remove(School item)
 {
     Context.Schools.Remove(item);
 }
 public void Add(School item)
 {
     Context.Schools.Add(item);
 }