public void GetCategoryChildrenLabelFromParentLabel_ReturnChildrenLabels() { // Given Category g1 = new Category { Id = 1, Label = "first" }; Category c1 = new Category { Id = 2, Label = "first c1" }; g1.AddCategory(c1); Category c2 = new Category { Id = 4, Label = "first c2" }; g1.AddCategory(c2); Category c3 = new Category { Id = 6, Label = "first c3" }; g1.AddCategory(c3); Category c4 = new Category { Id = 5, Label = "first c4" }; g1.AddCategory(c4); var repoMock = new Moq.Mock<IRepository>(); repoMock.Setup(x => x.Get<Category>(1)).Returns(g1); CategoryServices service = new CategoryServices(repoMock.Object, null); // When IList<String> result = service.GetCategoryChildrenLabelFromParentId(1); // Then Assert.AreEqual("FIRST C1", result[0]); Assert.AreEqual("FIRST C2", result[1]); Assert.AreEqual("FIRST C3", result[2]); Assert.AreEqual("FIRST C4", result[3]); }
public void GetCategoryChildrenLabelFromParentLabel_NoChildren_Returns_null() { // Given Category g1 = new Category { Id = 1, Label = "first" }; var repoMock = new Moq.Mock<IRepository>(); repoMock.Setup(x => x.Get<Category>(1)).Returns(g1); CategoryServices service = new CategoryServices(repoMock.Object, null); // When IList<String> result = service.GetCategoryChildrenLabelFromParentId(1); // Then Assert.IsNull(result); }