public void Get_Category_Should_Return_Category_With_SameID() { var context = new TestCategoryContext(); context.Categories.Add(GetDemoCategory()); var controller = new CategoriesController(context); var result = controller.GetCategory(3) as OkNegotiatedContentResult<Category>; Assert.IsNotNull(result); Assert.AreEqual(3, result.Content.CategoryId); }
public void Delete_Category_Should_ReturnOK() { var context = new TestCategoryContext(); var item = GetDemoCategory(); context.Categories.Add(item); var controller = new CategoriesController(context); var result = controller.DeleteCategory(3) as OkNegotiatedContentResult<Category>; Assert.IsNotNull(result); Assert.AreEqual(item.CategoryId, result.Content.CategoryId); }
public void Get_Categories_Should_Return_AllCategories() { var context = new TestCategoryContext(); context.Categories.Add(new Category { CategoryId = 1, Category_Name ="Demo1"}); context.Categories.Add(new Category { CategoryId = 2, Category_Name = "Demo2" }); context.Categories.Add(new Category { CategoryId = 3, Category_Name = "Demo3" }); var controller = new CategoriesController(context); var result = controller.GetCategories() as TestCategoryDBset; Assert.IsNotNull(result); Assert.AreEqual(3, result.Local.Count); }