public void GivenACategory_WhenUpdate_ThenContextSetsModified()
        {
            var expected = new Category { Id = 1 };

            Target.Update(expected);

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

            Target.Remove(item);

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

            Target.Add(expected);

            MockDbSet.AssertWasCalled(m => m.Add(expected));
        }
コード例 #4
0
        public void GivenAnUnassociatedServiceTypeAndCategory_WhenAddLink_ThenTheyAreAssociated()
        {
            ServiceType serviceType = new ServiceType();
            Category category = new Category();

            Target.AddLink(serviceType, category);

            CollectionAssert.Contains(serviceType.Categories.ToList(), category);
            CollectionAssert.Contains(category.ServiceTypes.ToList(), serviceType);
        }
コード例 #5
0
        public void GivenAnAssociatedServiceTypeAndCategory_WhenDeleteLink_TheyAreNoLongerAssociated()
        {
            ServiceType serviceType = new ServiceType();
            Category category = new Category { ServiceTypes = new List<ServiceType> { serviceType } };
            serviceType.Categories.Add(category);

            Target.DeleteLink(serviceType, category);

            CollectionAssert.DoesNotContain(serviceType.Categories.ToList(), category);
            CollectionAssert.DoesNotContain(category.ServiceTypes.ToList(), serviceType);
        }
コード例 #6
0
 public void DeleteLink(ServiceType serviceType, Category category)
 {
     if (serviceType == null)
     {
         throw new ArgumentNullException("serviceType");
     }
     if (category == null)
     {
         throw new ArgumentNullException("category");
     }
     serviceType.Categories.Remove(category);
     category.ServiceTypes.Remove(serviceType);
 }
 public void Update(Category item)
 {
     Context.SetModified(item);
 }
 public void Remove(Category item)
 {
     Context.Categories.Remove(item);
 }
 public void Add(Category item)
 {
     Context.Categories.Add(item);
 }
コード例 #10
0
        public void GivenNullServiceType_WhenDeleteLink_ThenThrowException()
        {
            Category category = new Category();

            Target.ExpectException<ArgumentNullException>(() => Target.DeleteLink(null, category));
        }