Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace CoffeeMachineSimulator.Services.Interfaces
public interface IEspressoMachineService
{
CoffeeModel GiveMeACoffee(SweetnessEnum sweetness);
float GetSumOfAllCoffees();
float GetSumOfAllCoffeesPrice();
List<CoffeeModel> MakeAllCoffeesWithSweetness(SweetnessEnum sweetness);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ public EspressoMachineService(ICoffeeService coffeeService)
this.coffeeService = coffeeService;
}

public float GetSumOfAllCoffees()
public float GetSumOfAllCoffeesPrice()
{
throw new System.NotImplementedException();
var allCoffeesFromList = coffeeService.GetCoffees();

float sumOfAllPrices = allCoffeesFromList.Sum(coffees => coffees.Price);
return sumOfAllPrices;
}

public CoffeeModel GiveMeACoffee(SweetnessEnum sweetness)
Expand All @@ -26,13 +29,18 @@ public CoffeeModel GiveMeACoffee(SweetnessEnum sweetness)

var myCoffeeToReturn = listOfCoffees.FirstOrDefault(x=>x.Sweetness == sweetness);
myCoffeeToReturn.Name = "TestMyCoffee";

return myCoffeeToReturn;
}

public List<CoffeeModel> MakeAllCoffeesWithSweetness(SweetnessEnum sweetness)
{
throw new System.NotImplementedException();
var allCoffeesFromList = coffeeService.GetCoffees();

foreach(CoffeeModel coffees in allCoffeesFromList)
{
coffees.Sweetness = sweetness;
}
return allCoffeesFromList;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,23 @@ private List<CoffeeModel> GetMockedCoffeeModels()
.Build()
.ToList();
}
[Test]
public void GetSumOfAllCoffeesPrice_ReturnsAllCoffeesPrice()
{
mockedCoffeeService.Setup(x => x.GetCoffees()).Returns(GetMockedCoffeeModels());
var serviceCoffees = new EspressoMachineService(mockedCoffeeService.Object);

Assert.IsNotNull(serviceCoffees.GetSumOfAllCoffeesPrice());
}

[Test]
public void MakeAllCoffeesWithSweetness_ReturnsAllCoffeeWithSueetness()
{
mockedCoffeeService.Setup(x => x.GetCoffees()).Returns(GetMockedCoffeeModels());
var serviceCoffees = new EspressoMachineService(mockedCoffeeService.Object);
var coffeesSweetness = serviceCoffees.MakeAllCoffeesWithSweetness(SweetnessEnum.LessSweet);

Assert.IsNotNull(coffeesSweetness);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CoffeeMachineSimulator.Tests.Services
{
internal class coffeeService
{
}
}