diff --git a/Screenshot 2024-08-14 112250.png b/Screenshot 2024-08-14 112250.png new file mode 100644 index 0000000..ee918ae Binary files /dev/null and b/Screenshot 2024-08-14 112250.png differ diff --git a/tdd-domain-modelling.CSharp.Main/CohortManager.cs b/tdd-domain-modelling.CSharp.Main/CohortManager.cs deleted file mode 100644 index 6a5669c..0000000 --- a/tdd-domain-modelling.CSharp.Main/CohortManager.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace tdd_domain_modelling.CSharp.Main -{ - public class CohortManager - { - } -} diff --git a/tdd-domain-modelling.CSharp.Main/ShoppingManager.cs b/tdd-domain-modelling.CSharp.Main/ShoppingManager.cs new file mode 100644 index 0000000..8530b75 --- /dev/null +++ b/tdd-domain-modelling.CSharp.Main/ShoppingManager.cs @@ -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 _basket = new Dictionary(); + + 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; + + } + + } +} diff --git a/tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs b/tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs deleted file mode 100644 index 56f3873..0000000 --- a/tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NUnit.Framework; -using tdd_domain_modelling.CSharp.Main; - -namespace tdd_domain_modelling.CSharp.Test -{ - [TestFixture] - public class CohortManagerTest - { - [Test] - public void FirstTest() - { - CohortManager core = new CohortManager(); - } - } -} \ No newline at end of file diff --git a/tdd-domain-modelling.CSharp.Test/ShoppingManagerTests.cs b/tdd-domain-modelling.CSharp.Test/ShoppingManagerTests.cs new file mode 100644 index 0000000..f212fd9 --- /dev/null +++ b/tdd-domain-modelling.CSharp.Test/ShoppingManagerTests.cs @@ -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); + + } + } +} \ No newline at end of file