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
45 changes: 44 additions & 1 deletion domain-model.md
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
#Domain Models In Here
#Domain Models In Here
```
As a supermarket shopper,
So that I can pay for products at checkout,
I'd like to be able to know the total cost of items in my basket.
```

Classes:
`Basket`

Methods:
`BasketTotal()` Summarize the total of all items in basket.
`CalculateSum()`

Scenario:
1. If basket is empty
2. If basket contains products

Output:
1. Output 0
2. Output totalprice


```
As an organised individual,
So that I can evaluate my shopping habits,
I'd like to see an itemised receipt that includes the name and price of the products
I bought as well as the quantity, and a total cost of my basket.
```

Classes:
`Basket` Create a basket to hold products

Methods:
`BasketTotal()` Summarize the total of products
`PrintReceipt()` Print a receipt of items + quantity, and totalprice.

Scenario:
1. If basket is empty
2. If basket contains products

Output:
1. Output 0
2. Output totalprice
4 changes: 3 additions & 1 deletion exercise1.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ So that I can pay for products at checkout,
I'd like to be able to know the total cost of items in my basket.
```

```


```
As an organised individual,
So that I can evaluate my shopping habits,
I'd like to see an itemised receipt that includes the name and price of the products
Expand Down
42 changes: 42 additions & 0 deletions tdd-domain-modelling.CSharp.Main/Basket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tdd_domain_modelling.csharp.main
{
public class Basket
{
private Dictionary<string, int> _basket = new Dictionary<string, int>();

public Dictionary<string, int> Add(string item, int price)
{
if (_basket.ContainsKey(item))
{
return _basket;
}
else
{
_basket.Add(item, price);
}
return _basket;
}
public int sum()
{
int totalSum = 0;
foreach (var item in _basket)
{
totalSum += item.Value;
}
return totalSum;
}





}

}

66 changes: 66 additions & 0 deletions tdd-domain-modelling.CSharp.Test/BasketTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using NUnit.Framework;
using tdd_domain_modelling.csharp.main;
using tdd_domain_modelling.CSharp.Main;



namespace tdd_domain_modelling.csharp.test
{
public class BasketTests
{
[Test]
public void FirstTest()
{

Basket basket = new Basket();
}


[TestCase("banana", 10)]
[TestCase("Pineapple", 5)]
public void Add(string item, int price)
{
//arrange
Basket basket = new Basket();

//act
Dictionary<string, int> _basket = basket.Add(item, price);

//assert
Assert.IsTrue(_basket.ContainsKey(item));
}

[TestCase("orange juice", 10)]
[TestCase("oat milk", 20)]
public void BooleanAddTest(string item, int price)
{
//arrange
Basket basket = new Basket();

//act
Dictionary<string, int> items = basket.Add(item, price);

//assert
Assert.IsTrue(items.ContainsKey(item));
}

[Test]
public void total()
{
//arrange
Basket basket = new Basket();
basket.Add("apple", 10);
basket.Add("banana", 5);
//act
int result = basket.sum();

//assert
Assert.IsTrue(result == 15);
}




}
}

7 changes: 7 additions & 0 deletions tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ public class CohortManagerTest
[Test]
public void FirstTest()
{
//arrange
CohortManager core = new CohortManager();

//act


//assert

}
}
}