private EntityCategory ConvertCategory(ModelCategory category)
 {
     return(new EntityCategory
     {
         Id = category.Id,
         Name = category.Name,
         Description = category.Description
     });
 }
        public void Set_PassedExistingProductWithOtherName_CountGoodRecordsInContextEqualsTwo()
        {
            var context  = CreateDataContext();
            var provider = CreateProvider(context);
            var category = new ModelCategory {
                Id = category_1, Name = "ChangedName"
            };
            var expectedRecordsCount = 2;

            provider.Set(category);

            var recordsCountInContext = context.Categories.Count();

            Assert.AreEqual(expectedRecordsCount, recordsCountInContext);
        }
        public void Set_PassedCollectionWithOneItemAndOneCategory_CountCategoriesInContextEqualsOne()
        {
            var context    = CreateDataContext();
            var provider   = CreateProvider(context);
            var newProduct = CreateNewProduct("NewProduct1");
            var category   = new ModelCategory {
                Id = category_1
            };

            newProduct.Categories.Add(category);
            var expectedRecordsCount = 1;

            provider.Set(newProduct);

            var recordsCountInContext = context.Categories.Count();

            Assert.AreEqual(expectedRecordsCount, recordsCountInContext);
        }