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 static IBarCode Convert(IDictionary <string, object> line, IBarCodeFactory barCodeFactory, ITransactionStorage transactionStorage) { var code = line["code"].ToString(); var isWeight = ((long)line["isWeight"] == 1); var numberOfDigits = System.Convert.ToInt32((long)line["numberOfDigits"]); var transactionId = (line["transactionId"] is System.DBNull) ? 0 : (long)line["transactionId"]; var barCode = barCodeFactory.CreateBarCode(code, isWeight, numberOfDigits); if (transactionId != 0) { barCode.Transaction = transactionStorage.GetAllTransactions().FirstOrDefault(x => x.Id == transactionId); } barCode.Id = (long)line["id"]; return(barCode); }
public IBarCode CreateBarCode(string code, bool isWeight, int numberOfDigits) { var barCode = BarCodeFactory.CreateBarCode(code, isWeight, numberOfDigits); return(CreateBarCode(barCode)); }