/// <summary> /// Adds Pizza item converting it into a Pizza entity to work with pizza /// repository. /// </summary> /// <param name="pizza"></param> /// <returns>Pizza item converted from returned pizza entity.</returns> public void Add(Pizza pizza) { var toppingEntities = pizza.Toppings != null? pizza.Toppings.Where(toppingModel => toppingService.GetByName(toppingModel.Name) != null) .Select(toppingModel => new ToppingEntity() { Name = toppingModel.Name }).ToList() : new List <ToppingEntity>(); pizzaRepository.Add(new PizzaEntity() { Name = pizza.Name, Toppings = toppingEntities }); }
public void TestGetByName() { var testToppingEntity = new ToppingEntity() { Name = "TestName" }; toppingRepositoryMock.Setup(m => m.GetByName("TestName")) .Returns(testToppingEntity); var result = sut.GetByName("TestName"); Assert.AreEqual(testToppingEntity.Name, result.Name); }