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
Binary file added Screenshot 2024-08-14 112250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 0 additions & 12 deletions tdd-domain-modelling.CSharp.Main/CohortManager.cs

This file was deleted.

43 changes: 43 additions & 0 deletions tdd-domain-modelling.CSharp.Main/ShoppingManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace tdd_domain_modelling.CSharp.Main
{
public class ShoppingManager
{

private Dictionary<string, int> _basket = new Dictionary<string, int>();

public bool Add(string product, int price)
{
_basket.Add("Banana", 4);

if (!_basket.ContainsKey(product))
{
_basket.Add(product, price);
return true;
}
else return false;

}


public int Total()
{
int totalCost = 0;

foreach (var product in _basket)
{
totalCost += product.Value;
}

return totalCost;

}

}
}
15 changes: 0 additions & 15 deletions tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs

This file was deleted.

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

namespace tdd_domain_modelling.CSharp.Test
{
[TestFixture]
public class ShoppingManagerTest
{
//As a supermarket shopper, So that I can restock my cupboard, I want to add products into my basket.
[Test]
public void AddProductsTest()
{
string product = "Apple";
int price = 5;
bool expected = true;
ShoppingManager shoppingManager = new ShoppingManager();

bool result = shoppingManager.Add(product, price);

Assert.AreEqual(expected, result);

}

[Test]
public void ProductAlreadyInBasketTest()
{
string product = "Banana";
int price = 4;
bool expected = false;
ShoppingManager shoppingManager = new ShoppingManager();

bool result = shoppingManager.Add(product, price);

Assert.AreEqual(expected, result);

}

//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,
[Test]
public void TotalCostOfBasketTest()
{

string product = "Apple";
int price = 5;
int expected = 9;
ShoppingManager shoppingManager = new ShoppingManager();

bool addproduct = shoppingManager.Add(product, price);
int result = shoppingManager.Total();

Assert.AreEqual(expected, result);

}
}
}