using System; using System.Collections.Generic; using System.Linq; using System.Data.Linq; using System.Text; using Chefbook.DataObjects; using NUnit.Framework; using Chefbook.UserActions; using Rhino.Mocks; using Chefbook.ViewModels; namespace UnitTests.UserActionsTests { [TestFixture] public class RemoveRecipeFromCategoryActionFixture { private MockRepository mocks; private IUserAction action; private CategoryViewModel category; private RecipeViewModel recipe; [SetUp] public void Init() { mocks = new MockRepository(); category = new CategoryViewModel(new Category(null)) { Name = "root" }; recipe = new RecipeViewModel(new Recipe(category.CategoryModel)) { Name = "MyRecipe" }; Assert.Contains(category, recipe.Categories); Assert.Contains(recipe, category.Recipes); action = new RemoveRecipeFromCategoryAction(recipe, category) ; } [Test] public void DoActionTest() { action.DoAction(); Assert.False(recipe.Categories.Contains(category),"Category not removed from Recipe"); Assert.False(category.Recipes.Contains(recipe), "Recipe not removed from Category"); } [Test] public void UndoActionTest() { action.DoAction(); action.UndoAction(); Assert.Contains(category, recipe.Categories); Assert.Contains(recipe, category.Recipes); } [Test] public void UndoActionWithoutDoingTest() { UserActionTestsHelper.UndoActionWithoutDoingTest(action); } [Test] public void UndoActionTwiceAfterDoingTest() { UserActionTestsHelper.UndoActionTwiceAfterDoingTest(action); } [Test] public void DoActionTwiceTest() { UserActionTestsHelper.DoActionTwiceTest(action); } [Test] public void ActionNameTest() { Assert.AreEqual(string.Format("Remove Recipe '{0}' from Category '{1}'", recipe, category), action.ToString()); } } }