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
33 changes: 33 additions & 0 deletions tdd-domain-modelling.CSharp.Main/Basket.cs
Original file line number Diff line number Diff line change
@@ -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<String, int> Items { get; set; }

//constructor
public Basket()
{
Items = new Dictionary<String, int>();
}
//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<int> totalValues = Items.Values.ToList();
return (totalValues.Sum());
}
}
}
14 changes: 14 additions & 0 deletions tdd-domain-modelling.CSharp.Main/CohortManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,19 @@ namespace tdd_domain_modelling.CSharp.Main
{
public class CohortManager
{
// properties
public List<string> Cohorts { get; set; }

public CohortManager()
{
Cohorts = new List<string> {"Cohort1", "Cohort2", "Cohort3"};
}

public bool isInList(string name)
{
return Cohorts.Contains(name);
}

}

}
7 changes: 7 additions & 0 deletions tdd-domain-modelling.CSharp.Main/DomainModelReceipt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Class Basket:
Properties
-ItemDict<dictionary> (string(itemname), float(prize))

Methods:
-totalPrice(); returns the sum of all values (prizes)
-list<strings>(); returns unitPrice, quantity, and name(string)
8 changes: 8 additions & 0 deletions tdd-domain-modelling.CSharp.Main/DomainModelShopper.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class: Basket

Properties
- List<String[]> ItemList (string Item, string ItemPrice)


Method:
- Int SumOfPrices(returns sum of prices) in ItemList
34 changes: 34 additions & 0 deletions tdd-domain-modelling.CSharp.Test/BasketTest.cs
Original file line number Diff line number Diff line change
@@ -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);

}
}
}
9 changes: 8 additions & 1 deletion tdd-domain-modelling.CSharp.Test/CohortManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}