diff --git a/tdd-domain-modelling.CSharp.Main/Basket.cs b/tdd-domain-modelling.CSharp.Main/Basket.cs new file mode 100644 index 0000000..70e7cd0 --- /dev/null +++ b/tdd-domain-modelling.CSharp.Main/Basket.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Collections; + +namespace tdd_domain_modelling.CSharp.Main +{ + public class Basket + { + // Properties + public Dictionary Items { get; set; } + + //constructor + public Basket() + { + Items = new Dictionary(); + } + //method1, add item to basket + public void addToBasket(String productName, int price) + { + Items.Add(productName, price); + + } + //method2, return the total price + public int total() + { + List totalValues = Items.Values.ToList(); + return (totalValues.Sum()); + } + } +} \ No newline at end of file diff --git a/tdd-domain-modelling.CSharp.Main/CohortManager.cs b/tdd-domain-modelling.CSharp.Main/CohortManager.cs index 6a5669c..cd0c07e 100644 --- a/tdd-domain-modelling.CSharp.Main/CohortManager.cs +++ b/tdd-domain-modelling.CSharp.Main/CohortManager.cs @@ -8,5 +8,19 @@ namespace tdd_domain_modelling.CSharp.Main { public class CohortManager { + // properties + public List Cohorts { get; set; } + + public CohortManager() + { + Cohorts = new List {"Cohort1", "Cohort2", "Cohort3"}; + } + + public bool isInList(string name) + { + return Cohorts.Contains(name); + } + } + } diff --git a/tdd-domain-modelling.CSharp.Main/DomainModelReceipt.txt b/tdd-domain-modelling.CSharp.Main/DomainModelReceipt.txt new file mode 100644 index 0000000..8e56dfd --- /dev/null +++ b/tdd-domain-modelling.CSharp.Main/DomainModelReceipt.txt @@ -0,0 +1,7 @@ +Class Basket: +Properties + -ItemDict (string(itemname), float(prize)) + +Methods: + -totalPrice(); returns the sum of all values (prizes) + -list(); returns unitPrice, quantity, and name(string) \ No newline at end of file diff --git a/tdd-domain-modelling.CSharp.Main/DomainModelShopper.txt b/tdd-domain-modelling.CSharp.Main/DomainModelShopper.txt new file mode 100644 index 0000000..fe4071d --- /dev/null +++ b/tdd-domain-modelling.CSharp.Main/DomainModelShopper.txt @@ -0,0 +1,8 @@ +class: Basket + +Properties +- List ItemList (string Item, string ItemPrice) + + +Method: +- Int SumOfPrices(returns sum of prices) in ItemList diff --git a/tdd-domain-modelling.CSharp.Test/BasketTest.cs b/tdd-domain-modelling.CSharp.Test/BasketTest.cs new file mode 100644 index 0000000..751ab41 --- /dev/null +++ b/tdd-domain-modelling.CSharp.Test/BasketTest.cs @@ -0,0 +1,34 @@ +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using tdd_domain_modelling.CSharp.Main; + +namespace tdd_domain_modelling.CSharp.Test +{ + [TestFixture] + public class BasketTest + { + [Test] + + public void firstBasketTest() + { + Basket core = new Basket(); + + core.addToBasket("Cola", 2); + core.addToBasket("Pepsimax", 3); + core.addToBasket("Fanta", 8); + + string[] expectedArray = { "Cola", "Pepsimax", "Fanta" }; + + string[] actualArray = core.Items.Keys.ToArray(); + + Assert.AreEqual(expectedArray, actualArray); + + Assert.AreEqual(core.total(), 13); + + } + } +} diff --git a/tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs b/tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs index 56f3873..b08a8de 100644 --- a/tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs +++ b/tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs @@ -8,8 +8,15 @@ public class CohortManagerTest { [Test] public void FirstTest() - { + { + //Arrange CohortManager core = new CohortManager(); + + + string cohortSearch = "Cohort1"; + bool result = core.isInList(cohortSearch); + + Assert.IsTrue(result); } } } \ No newline at end of file