public void Setup() { _transactionStorage = new MemoryTransactionStorage(new RegularTransactionFactory()); _storage = new MemoryBarCodeStorage(new BarCodeFactory(), _transactionStorage); _storage.CreateBarCode("55555555555", false, 0); _storage.CreateBarCode("44444444444", true, 5); }
public void DeleteBarCodeTest() { var barCodeStorage = new MemoryBarCodeStorage(new BarCodeFactory(), new MemoryTransactionStorage(new RegularTransactionFactory())); var barCode = barCodeStorage.CreateBarCode(CreateBarCode("2734336010584", true, 6)); barCodeStorage.CreateBarCode(CreateBarCode("5060207697224")); barCodeStorage.DeleteBarCode(barCode); var codes = barCodeStorage.GetAllBarCodes(); Assert.AreEqual(1, codes.Count()); }
public void CreateTwoBarCodesWithSameCodeTest() { var barCode1 = _factory.CreateBarCode(SilpoZefir, true, 6, 99L); var barCode2 = _factory.CreateBarCode(BarCode2, false, 0, 99L); _storage.CreateBarCode(barCode1); _storage.CreateBarCode(barCode2); var newBarCode = _storage.GetAllBarCodes().FirstOrDefault(); Assert.IsNotNull(newBarCode); Assert.AreEqual(1, _storage.GetAllBarCodes().Count()); Assert.AreEqual(barCode2.Code, newBarCode.Code); Assert.AreEqual(barCode2.IsWeight, newBarCode.IsWeight); Assert.AreEqual(99L, newBarCode.Id); }
public void CreateNonWeightBarCodeTest() { const string code = "5060207697224"; var barCodeStorage = new MemoryBarCodeStorage(new BarCodeFactory(), new MemoryTransactionStorage(new RegularTransactionFactory())); var barCode = barCodeStorage.CreateBarCode(CreateBarCode(code)); Assert.AreEqual(code, barCode.GetProductBarCode()); Assert.AreEqual(0m, barCode.GetWeightKg()); }
public void CreateBarCodeBasedTransactionText() { var transactionStorage = new MemoryTransactionStorage(new RegularTransactionFactory()); var barCodeStorage = new MemoryBarCodeStorage(new BarCodeFactory(), transactionStorage); var accountFactory = new RegularAccountFactory(); var categoryFactory = new RegularCategoryFactory(); var account = accountFactory.CreateAccount("Account", "Description", "UAH"); var category = categoryFactory.CreateCategory("Category", "category Description", 0, null); var transaction = transactionStorage.CreateTransaction(account, category, "test", 26.38m, DateTime.Now, 0, 0, null, null); var barCode = barCodeStorage.CreateBarCode(CreateBarCode("2734336010584", true, 6)); barCode.Transaction = transaction; barCodeStorage.UpdateBarCode(barCode); barCodeStorage.CreateBarCode(CreateBarCode("5060207697224")); barCodeStorage.CreateTransactionBarCodeRelatedFromStorage("2734336"); var transactions = transactionStorage.GetAllTransactions(); Assert.AreEqual(2, transactions.Count()); }
public void CreateBarCodeTest() { const string code = "2734336010584"; const bool isWeight = true; const int numberOfDigits = 6; var barCodeStorage = new MemoryBarCodeStorage(new BarCodeFactory(), new MemoryTransactionStorage(new RegularTransactionFactory())); var barCode = barCodeStorage.CreateBarCode(CreateBarCode(code, isWeight, numberOfDigits)); Assert.AreEqual("2734336", barCode.GetProductBarCode()); Assert.AreEqual(1.058m, barCode.GetWeightKg()); }