public void Given_CDBA_TotalPrice_ShouldBe_115() { Till till = new Till(); till.Scan("CDBA"); NUnit.Framework.Assert.AreEqual(115.0, till.Total()); }
public void ForEmptyTillTotalIsZero() { var till = new Till(); var total = till.TotalCost(); Assert.True(total == 0); }
public void CanAddItemToTill() { var till = new Till(); till.Items.Add(new TillItem(TillItemType.Main(), 1)); Assert.True(till.Items.Count == 1); }
/// <summary> /// Get the tills which are not pay at pump /// </summary> /// <param name="payAtPumpTill">aPay at pump till</param> /// <returns>Tills</returns> public List <Till> GetnotPayAtPumpTill(int payAtPumpTill) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,TillService,GetnotPayAtPumpTill,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}"); var strSql = "Select * FROM Tills WHERE Tills.Till_Num <> " + payAtPumpTill + ""; var sTills = GetRecords(strSql, DataSource.CSCMaster); var tills = new List <Till>(); foreach (DataRow row in sTills.Rows) { var till = new Till { Number = CommonUtility.GetShortValue(row["TILL_NUM"]), Active = CommonUtility.GetBooleanValue(row["ACTIVE"]), Processing = CommonUtility.GetBooleanValue(row["PROCESS"]), Float = CommonUtility.GetDecimalValue(row["FLOAT"]), BonusFloat = CommonUtility.GetDecimalValue(row["CashBonusFloat"]), Cash = CommonUtility.GetDecimalValue(row["CASH"]), Date_Open = CommonUtility.GetDateTimeValue(row["DATE_OPEN"]), Time_Open = CommonUtility.GetDateTimeValue(row["TIME_OPEN"]), ShiftDate = CommonUtility.GetDateTimeValue(row["ShiftDate"]), Shift = CommonUtility.GetShortValue(row["ShiftNumber"]), UserLoggedOn = CommonUtility.GetStringValue(row["UserLoggedOn"]), POSId = CommonUtility.GetIntergerValue(row["POSID"]), CashBonus = CommonUtility.GetDecimalValue(row["CashBonus"]) }; tills.Add(till); } _performancelog.Debug($"End,TillService,GetnotPayAtPumpTill,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(tills); }
public void attempt_spend_more_than_holdings() { till = new Till(0, 0, 0, 0, 0); till.insertMoney(Currency.QUARTER); till.spend(50); Assert.True(till.bank[Currency.QUARTER] == 1 && till.holdings == 25); }
/// <summary> /// Get the Till by Till Number /// </summary> /// <param name="tillNumber">Till number</param> /// <returns>Till</returns> public Till GetTill(int tillNumber) { var sTill = GetRecords("Select * From Tills where till_num=" + tillNumber, DataSource.CSCMaster); if (sTill.Rows.Count > 0) { var row = sTill.Rows[0]; var till = new Till { Number = CommonUtility.GetShortValue(row["TILL_NUM"]), Active = CommonUtility.GetBooleanValue(row["ACTIVE"]), Processing = CommonUtility.GetBooleanValue(row["PROCESS"]), Float = CommonUtility.GetDecimalValue(row["FLOAT"]), BonusFloat = CommonUtility.GetDecimalValue(row["CashBonusFloat"]), Cash = CommonUtility.GetDecimalValue(row["CASH"]), Date_Open = CommonUtility.GetDateTimeValue(row["DATE_OPEN"]), Time_Open = CommonUtility.GetDateTimeValue(row["TIME_OPEN"]), ShiftDate = CommonUtility.GetDateTimeValue(row["ShiftDate"]), Shift = CommonUtility.GetShortValue(row["ShiftNumber"]), UserLoggedOn = CommonUtility.GetStringValue(row["UserLoggedOn"]), POSId = CommonUtility.GetIntergerValue(row["POSID"]), CashBonus = CommonUtility.GetDecimalValue(row["CashBonus"]) }; return(till); } return(null); }
public SupermarketTest5() { till = new Till( new Dictionary <string, int> { { "Apple", applePrice }, { "Banana", bananaPrice } }); }
static void productList(Till Till) { Console.WriteLine("Lista Produktów:"); Till.Products.ForEach(product => { Console.WriteLine($"{product.Kod}. {product.Produkt} - {product.Cena} PLN"); }); UserSelect(Till); }
public void CalculateBill_ShouldHandleDuplicatesCorrectly() { var items = new List <string> { "Cheese Sandwich", "Cheese Sandwich" }; var result = Till.CalculateBill(items); Assert.Equal(4.4m, result); }
public void attemptToVend_changeCannotBeMade_vendFails_thenAddProperChange_vendSucceeds() { Till till = new Till(0, 0, 0, 0, 1); //one dollar. VendingMachine machine = new VendingMachine(inv_2x2, till); //reconstruct vendingmachine with new till machine.insertCurrency(Currency.DOLLAR, 1); //insert $1 Assert.False(machine.vend(0, 0), "Vending should have failed due to inability to return exact change, but vend() returned true anyway."); machine.insertCurrency(Currency.QUARTER, 3); //machine now holds 3 quarters and two dollars. Exact change can be made Assert.True(machine.vend(0, 0), "Item should have been able to vend, but it failed to do so."); }
public void Given_TwoItemsOfTypeA_TotalPrice_ShouldBe_100() { // Arrange Till till = new Till(); // Act till.Scan("AA"); Assert.AreEqual(100, till.Total()); }
public void CalculateBill_ShouldHandleNullItemsCorrectly() { var items = new List <string> { "No Item" }; var exception = Record.Exception(() => Till.CalculateBill(items)); Assert.NotNull(exception); Assert.IsType <NullReferenceException>(exception); }
public void GetOrderType_Returns_AllDrinks_IfAllDrinks() { var products = new List <Product>() { new Product(name: "Drink1", cost: 0, type: ProductType.Drink, isHot: false) }; var orderType = Till.GetOrderType(products); Assert.Equal(OrderType.AllDrinks, orderType); }
public void CanIncrementItemQuantityInTill() { var items = new List <TillItem>() { new TillItem(TillItemType.Starter(), 1) }; var till = new Till(items); till.Items.First().IncrementQuantity(); Assert.True(till.Items.First().Quantity == 2); }
public void Given_AB_TotalPrice_ShouldBe_80() { // Arrange var till = new Till(); // Act till.Scan("AB");//What I did is removing the code "new Till().Scan("AB");", it will be "till.Scan("AB")" // Assert Assert.AreEqual(80.0, till.Total()); }
public void TestConstructor() { // Prepare // Run var sut = new Till(new TestProductCatalogus()); // SUT = Software Under Test // Analyze Assert.NotNull(sut); // We expect that 'SUT' is a valid object Assert.IsInstanceOf <ITill>(sut); // We expect that it implements the ITill interface }
public void GetOrderType_Returns_ContainsHotFood_IfAnyHotFood() { var products = new List <Product>() { new Product(name: "Cold Food1", cost: 0, type: ProductType.Food, isHot: false), new Product(name: "Hot Food1", cost: 0, type: ProductType.Food, isHot: true) }; var orderType = Till.GetOrderType(products); Assert.Equal(OrderType.ContainsHotFood, orderType); }
static void Main(string[] args) { // Make a new 'till' based on the ITill interface ITill till = new Till(new ProductCatalog()); // Construct a console interaction file var consoleInteraction = new ConsoleTillDisplay(till); // Start the main loop consoleInteraction.Run(); }
public void CanNotDecrementItemIfQuantityIsOneInTillIs() { var items = new List <TillItem>() { new TillItem(TillItemType.Starter(), 1) }; var till = new Till(items); till.Items.First().DecrementQuantity(); Assert.True(till.Items.First().Quantity == 1); }
public void Given_7CItems_TotalPrice_ShouldBe_120()// Added an extra test to check the Max of 6 items { // Arrange Till till = new Till(); // Act till.Scan("CCCCCCC"); // Assert Assert.AreEqual(120, till.Total()); }
public void Given_TwoAAItems_TotalPrice_ShouldBe_100() //Was ShouldBe_110 { // Arrange Till till = new Till(); // Act till.Scan("Aa"); // Assert Assert.AreEqual(100, till.Total()); //Was 45. }
public void Given_TwoAAItems_TotalPrice_ShouldBe_180() { // Arrange Till till = new Till(); // Act till.Scan("AAAA"); // Assert Assert.AreEqual(180, till.Total()); }
public void Given_TwoAAItems_TotalPrice_ShouldBe_180()// This is wrong so I changed it to be two AA items test should be { // Arrange Till till = new Till(); // Act till.Scan("AAAA"); // Assert Assert.AreEqual(180, till.Total()); }
public void Given_TwoItemsOfTypeB_TotalPrice_ShouldBe_45() { // Arrange Till till = new Till(); // Act till.Scan("BB"); // Assert Assert.AreEqual(45, till.Total()); }
public void Test0() { // Arrange Till till = new Till(); // Act // Scan nothing // NUnit.Framework.Assert.AreEqual(0, till.Total()); }
public void Given_AB_TotalPrice_ShouldBe_80() { // Arrange var till = new Till(); // Act till.Scan("AB"); // Assert NUnit.Framework.Assert.AreEqual(80.0, till.Total()); }
public void CanScanMultipleBaskets() { new List <string> { "A", "B", "C", "D" }.ForEach(_till.Scan); _till = _till.CompleteSale(); _till.Display.Subscribe(si => _items.Add(si)); new List <string> { "A", "B", "B", "C", "A" }.ForEach(_till.Scan); _items.Should().BeEquivalentTo(new [] { 50, 80, 140, 239, 50, 80, 95, 155, 205 }); }
// Assigns a staff member to the till. 0: cannot assign; 1: can assign; public int assignStaff(Till till, Staff st) { if (till.staff.Equals(null)) // If there is no staff member assigned, assign a staff member. { till.staff = st; return(1); } else // If there is a staff member assigned, you cannot assign another. { return(0); } }
// Removes a staff member from the till. 0: cannot remove; 1: can remove; public int removeStaff(Till till) { if (!till.staff.Equals(null)) // If there is a staff member assigned, remove them. { till.staff = null; return(1); } else // If there is not staff member assigned, you cannot remove them. { return(0); } }
public void Given_TwoAAItems_TotalPrice_ShouldBe_110() { // Arrange Till till = new Till(); // Act till.Scan("Aa".ToUpper()); // Assert //Change from 45 to 110, and let total + 10; Assert.AreEqual(110, till.Total() + 10); }