public async void GetByProductNoAsyncTest() { string productNo = "P002"; Dtos.ProductDto product = await productService.GetByProductNoAsync(productNo); Assert.True(product.ProductNo == productNo, "This test needs an implementation"); }
public void PrintBarCode(Dtos.ProductDto product, uint printNum = 1, uint repeatNum = 1) { switch (CurrentBarCodePrinter) { case "ZMIN X1": new ZMINPrinter().Print(CurrentBarCodePrinter, product, CurrentSettings, printNum, repeatNum); break; } }
public async void ProductCreatedDateLargerthantimebeforeAdd() { var dateBeforeAdd = DateTime.UtcNow; string name = "New Product Name"; Dtos.ProductDto newProduct = await productService.AddProductAsync(new Dtos.ProductDto { Name = name }); Assert.True(newProduct.CreatedDate > dateBeforeAdd); }
public async void DeleteProductAsyncTest() { string productNo = "P001"; await productService.DeleteProductAsync(productNo); IEnumerable <Dtos.ProductDto> products = await productService.GetAllAsync(); Dtos.ProductDto productShouldBeNull = await productService.GetByProductNoAsync(productNo); Assert.True(products.ToList().Count == 2, "Error not correct amount of products"); Assert.True(productShouldBeNull is null, "¨Product not deleted"); }
public void Print(string currentPrinter, Dtos.ProductDto product, BarCodePrintSettings format, uint printNum = 1, uint repeatNum = 1) { //var settings = format as ZMINPrinterSettings; //PrinterApi.OpenPort(currentPrinter); //打开打印机端口,打印机驱动的名称一定要正确 //PrinterApi.ZM_ClearBuffer(); //清空缓冲区 //PrinterApi.ZM_SetPrintSpeed(settings.PrintSpeed); //设置打印速度,4是4英寸/秒,6是6英寸/秒(X1最高是6,X1i最高是4) //PrinterApi.ZM_SetDarkness(settings.SetDarkness); //设置打印黑度(也是打印温度,最高是20,一般蜡质碳带设置为10,混合基碳带设置为12,树脂基碳带设置为18) //PrinterApi.ZM_SetLabelHeight(settings.LabelHeight, settings.GapHeight); //设置标签的高度和标签之间的行间隙,里面的数值是像素值(200dpi是8点/毫米,300dpi是11.8点/毫米,如果计算出小数需取整) //PrinterApi.ZM_SetLabelWidth(settings.LabelWidth); //设置标签的宽度 //// 开始打印 //try //{ // var formats = settings.Format.Split(new String[] { "@NEW@" }, StringSplitOptions.RemoveEmptyEntries); // foreach (var item in formats) // { // var results = item.Split(new string[] { "&&&" }, StringSplitOptions.RemoveEmptyEntries); // if (results.Count() > 1) // { // var configs = results[1].Split(new string[] { "##" }, StringSplitOptions.RemoveEmptyEntries); // switch (results.FirstOrDefault()) // { // case "Barcode": // DrawBarcode(product.Barcode, uint.Parse(configs[0]), uint.Parse(configs[1]), uint.Parse(configs[2]), uint.Parse(configs[3]), uint.Parse(configs[4])); // break; // case "Text": // switch (configs[0]) // { // case "@Barcode@": // DrawText(product.Barcode, int.Parse(configs[1]), int.Parse(configs[2]), int.Parse(configs[3]), int.Parse(configs[4]), configs[5]); // break; // case "@ProductTitle@": // DrawText(product.Title, int.Parse(configs[1]), int.Parse(configs[2]), int.Parse(configs[3]), int.Parse(configs[4]), configs[5]); // break; // case "@Price@": // DrawText(product.SysPrice.ToString("C", CultureInfo.CreateSpecificCulture("zh-CN")), int.Parse(configs[1]), int.Parse(configs[2]), int.Parse(configs[3]), int.Parse(configs[4]), configs[5]); // break; // default: // DrawText(configs[0], int.Parse(configs[1]), int.Parse(configs[2]), int.Parse(configs[3]), int.Parse(configs[4]), configs[5]); // break; // } // break; // } // } // } //} //catch //{ // MessageBox.Show("模板解析失败!"); //} //PrinterApi.ZM_PrinterApiel(printNum, repeatNum);//number:打印标签的数量,cpnumber:每张标签的复制份数 ////关闭打印机端口 //PrinterApi.ClosePort(); if (product.IsWeigh) { PrinterApi.OpenPort("ZMIN X1"); //打开打印机端口,打印机驱动的名称一定要正确 PrinterApi.ZM_ClearBuffer(); //清空缓冲区 PrinterApi.ZM_SetPrintSpeed(4); //设置打印速度,4是4英寸/秒,6是6英寸/秒(X1最高是6,X1i最高是4) PrinterApi.ZM_SetDarkness(10); //设置打印黑度(也是打印温度,最高是20,一般蜡质碳带设置为10,混合基碳带设置为12,树脂基碳带设置为18) PrinterApi.ZM_SetLabelHeight(200, 16); //设置标签的高度和标签之间的行间隙,里面的数值是像素值(200dpi是8点/毫米,300dpi是11.8点/毫米,如果计算出小数需取整) PrinterApi.ZM_SetLabelWidth(800); //设置标签的宽度 PrintByType(3, product.ProductCode, product.Title, product.SysPrice, product.Unit); // 开始打印 PrinterApi.ZM_PrintLabel(1, 1);//number:打印标签的数量,cpnumber:每张标签的复制份数 //关闭打印机端口 PrinterApi.ClosePort(); } else if (product.Barcode.Length >= 13) { PrinterApi.OpenPort("ZMIN X1"); //打开打印机端口,打印机驱动的名称一定要正确 PrinterApi.ZM_ClearBuffer(); //清空缓冲区 PrinterApi.ZM_SetPrintSpeed(4); //设置打印速度,4是4英寸/秒,6是6英寸/秒(X1最高是6,X1i最高是4) PrinterApi.ZM_SetDarkness(10); //设置打印黑度(也是打印温度,最高是20,一般蜡质碳带设置为10,混合基碳带设置为12,树脂基碳带设置为18) PrinterApi.ZM_SetLabelHeight(200, 16); //设置标签的高度和标签之间的行间隙,里面的数值是像素值(200dpi是8点/毫米,300dpi是11.8点/毫米,如果计算出小数需取整) PrinterApi.ZM_SetLabelWidth(800); //设置标签的宽度 PrintByType(2, product.Barcode, product.Title, product.SysPrice, product.Unit); // 开始打印 PrinterApi.ZM_PrintLabel(1, 1);//number:打印标签的数量,cpnumber:每张标签的复制份数 //关闭打印机端口 PrinterApi.ClosePort(); } else if (product.Barcode.Length >= 10 && product.Barcode.Length < 13) { PrinterApi.OpenPort("ZMIN X1"); //打开打印机端口,打印机驱动的名称一定要正确 PrinterApi.ZM_ClearBuffer(); //清空缓冲区 PrinterApi.ZM_SetPrintSpeed(2); //设置打印速度,4是4英寸/秒,6是6英寸/秒(X1最高是6,X1i最高是4) PrinterApi.ZM_SetDarkness(8); //设置打印黑度(也是打印温度,最高是20,一般蜡质碳带设置为10,混合基碳带设置为12,树脂基碳带设置为18) PrinterApi.ZM_SetLabelHeight(200, 16); //设置标签的高度和标签之间的行间隙,里面的数值是像素值(200dpi是8点/毫米,300dpi是11.8点/毫米,如果计算出小数需取整) PrinterApi.ZM_SetLabelWidth(800); //设置标签的宽度 PrintByType(1, product.Barcode, product.Title, product.SysPrice, product.Unit); // 开始打印 PrinterApi.ZM_PrintLabel(1, 1);//number:打印标签的数量,cpnumber:每张标签的复制份数 //关闭打印机端口 PrinterApi.ClosePort(); } //switch() //{ //} }