public void AddRecipe_AddsChildRecipeToParentRecipe_GivenParentId() { //Arrange var title = "Almost completely new recipe"; var description = "Almost completely new description"; var parentAncestryPath = "3/11/"; var expectedNode = new RecipeNode() { RecipeID = 12, AncestryPath = "3/11/12/" }; var expectedLogEntry = new RecipeLogEntry() { VersionID = 15, RecipeID = 12, Title = title, Description = description }; //Act var recipeId = _repo.AddRecipe(title, description, parentAncestryPath); var actualNode = _repo.GetRecipeNode(recipeId); var actualLogEntry = _repo.GetLatestLogEntryFor(recipeId); //Assert Assert.True(recipeId > 0); Assert.Equal(actualNode, expectedNode, new NodeEqualityComparer()); Assert.Equal(actualLogEntry, expectedLogEntry, new LogEntryEqualityComparer()); _fixture.ResetRepository(); }
public void AddRecipe_AddsRecipeToRootLevelWithNewId_GivenNoParentAncestryPath() { //Arrange var title = "Completely new recipe"; var description = "Completely new description"; string parentAncestryPath = null; var expectedNode = new RecipeNode() { RecipeID = 12, AncestryPath = "12/" }; var expectedLogEntry = new RecipeLogEntry() { VersionID = 15, RecipeID = 12, Title = title, Description = description }; //Act var recipeId = _repo.AddRecipe(title, description, parentAncestryPath); var actualNode = _repo.GetRecipeNode(recipeId); var actualLogEntry = _repo.GetLatestLogEntryFor(recipeId); //Assert Assert.True(recipeId > 0); Assert.Equal(actualNode, expectedNode, new NodeEqualityComparer()); Assert.Equal(actualLogEntry, expectedLogEntry, new LogEntryEqualityComparer()); _fixture.ResetRepository(); }