public void ZebraZC3_PrintNameOnCard() { //Zebra.Sdk.Comm.ConnectionException var printers = ZebraZC3.GetPrinterList(); using (var printer = printers[0]) { printer.Connect(); ProductField nameOnCardField = new ProductField { Deleted = false, Printable = true, X = 500, Y = 200, Value = Encoding.UTF8.GetBytes("DANIEL JACOB"), Font = "Consolas", FontColourRGB = Color.Black.ToArgb(), FontSize = 10, PrintSide = 0 }; var printDetail = printer.PrinterDetailFactory().Populate(new ProductField[] { nameOnCardField }); printer.Print("123456789", printDetail); } }
public void PrintSimDetailFactory_PopulateWithTwoFrontImageFields_FirstFrontPanelFieldSetCorrectly() { // Arrange var simDetailFactory = new PrintSimDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 0, Width = 100, Height = 200, ProductPrintFieldTypeId = 1, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 0, Width = 430, Height = 789, ProductPrintFieldTypeId = 1, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") } }; var firstField = productFields[0]; var firstImageField = new PrintSimCardImageDetail(firstField.Value, firstField.X, firstField.Y, firstField.Width, firstField.Height); // Act var simPrintDetails = simDetailFactory.Populate(productFields); // Assert simPrintDetails.FrontPanelImages[0].Should().BeEquivalentTo(firstImageField); }
public void ZebraDetailFactory_PopulateWithTwoBackTextFields_SecondBackPanelFieldSetCorrectly() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, Font = "consolas", PrintSide = 1, FontColourRGB = Color.Black.ToArgb(), FontSize = 10, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, Font = "arial", PrintSide = 1, FontColourRGB = Color.Red.ToArgb(), FontSize = 12, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") } }; var secondField = productFields[1]; var secondTextField = new ZebraCardTextDetail(secondField.ValueToString(), secondField.X, secondField.Y, secondField.Font, secondField.FontSize, secondField.FontColourRGB, FontStyle.Regular); // Act var simPrintDetails = zebraDetailFactory.Populate(productFields); // Assert simPrintDetails.BackPanelText[1].Should().BeEquivalentTo(secondTextField); }
public void ZebraDetailFactory_PopulateWithBackImageFields_OnlyHaveBackImageFieldsPopulated() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 100, Height = 200, ProductPrintFieldTypeId = 1, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 430, Height = 789, ProductPrintFieldTypeId = 1, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") } }; // Act var simPrintDetails = zebraDetailFactory.Populate(productFields); // Assert simPrintDetails.FrontPanelText.Length.Should().Be(0, because: "No text fields passed to Populate()"); simPrintDetails.BackPanelText.Length.Should().Be(0, because: "No text fields passed to Populate()"); simPrintDetails.FrontPanelImages.Length.Should().Be(0, because: "No front side image fields passed to Populate()"); simPrintDetails.BackPanelImages.Length.Should().Be(2, because: "Two back side image field passed to Populate(). Must set two BackPanelImages objects."); }
public void PrintSimDetailFactory_PopulateWithTwoFrontTextFields_FirstFrontPanelFieldSetCorrectly() { // Arrange var simDetailFactory = new PrintSimDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, Font = "consolas", PrintSide = 0, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Black.ToArgb(), FontSize = 10, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, Font = "arial", PrintSide = 0, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Red.ToArgb(), FontSize = 12, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") } }; var firstField = productFields[0]; var firstTextField = new PrintSimCardTextDetail(firstField.ValueToString(), firstField.X, firstField.Y, firstField.Font, firstField.FontSize, firstField.FontColourRGB, FontStyle.Regular); // Act var simPrintDetails = simDetailFactory.Populate(productFields); // Assert simPrintDetails.FrontPanelText[0].Should().BeEquivalentTo(firstTextField); }
protected void lnk_Delete_Click(object sender, System.EventArgs e) { if (!base.IsAuthorizedOp(ActionType.Delete.ToString())) { base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền"); } else { int @int = WebUtils.GetInt((sender as LinkButton).CommandArgument); ProductFieldInfo dataById = ProductField.GetDataById(@int); if (dataById == null) { base.ShowAjaxMsg(this.UpdatePanel1, "Những thông tin này không được tìm thấy, các dữ liệu không tồn tại hoặc đã bị xóa"); } else if (dataById.IsSystem) { base.ShowAjaxMsg(this.UpdatePanel1, "Lĩnh vực thuộc hệ thống không thể bị xóa"); } else if (ProductField.Delete(@int)) { this.BindData(); PageBase.log.AddEvent(base.LoginAccount.AccountName, "Xóa trường [" + dataById.FieldName + "] thành công"); base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công"); } else { base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thất bại"); } } }
public void ZebraDetailFactory_PopulateWithTwoBackImageFields_SecondBackPanelFieldSetCorrectly() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 100, Height = 200, ProductPrintFieldTypeId = 1, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 430, Height = 789, ProductPrintFieldTypeId = 1, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") } }; var secondField = productFields[1]; var secondImageField = new ZebraCardImageDetail(secondField.Value, secondField.X, secondField.Y, secondField.Width, secondField.Height); // Act var simPrintDetails = zebraDetailFactory.Populate(productFields); // Assert simPrintDetails.BackPanelImages[1].Should().BeEquivalentTo(secondImageField); }
public void ZebraDetailFactory_PopulateWithMixedFields_CheckFieldsAllocatedCorrectly() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, Font = "consolas", PrintSide = 0, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Black.ToArgb(), FontSize = 10, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, Font = "arial", PrintSide = 1, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Red.ToArgb(), FontSize = 12, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 0, Width = 100, Height = 200, ProductPrintFieldTypeId = 1, X = 43, Y = 66, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 3") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 430, Height = 789, ProductPrintFieldTypeId = 1, X = 5, Y = 9, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 4") } }; // Act var simPrintDetails = zebraDetailFactory.Populate(productFields); // Assert simPrintDetails.BackPanelText.Length.Should().Be(1); simPrintDetails.BackPanelImages.Length.Should().Be(1); simPrintDetails.FrontPanelText.Length.Should().Be(1); simPrintDetails.FrontPanelImages.Length.Should().Be(1); }
public void ZebraDetailFactory_PopulateWithBackMixedFields_OnlyHaveBackFieldsPopulated() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, Font = "consolas", PrintSide = 1, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Black.ToArgb(), FontSize = 10, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, Font = "arial", PrintSide = 1, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Red.ToArgb(), FontSize = 12, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 100, Height = 200, ProductPrintFieldTypeId = 1, X = 43, Y = 66, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 3") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 430, Height = 789, ProductPrintFieldTypeId = 1, X = 5, Y = 9, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 4") } }; // Act var simPrintDetails = zebraDetailFactory.Populate(productFields); // Assert simPrintDetails.BackPanelText.Length.Should().Be(2, because: "Two back side text field passed to Populate(). Must set two BackPanelText objects."); simPrintDetails.BackPanelImages.Length.Should().Be(2, because: "Two back side image field passed to Populate(). Must set two BackPanelImages objects."); simPrintDetails.FrontPanelText.Length.Should().Be(0, because: "No front fields passed to Populate()"); simPrintDetails.FrontPanelImages.Length.Should().Be(0, because: "No front fields passed to Populate()"); }
public void ZebraDetailFactory_PopulateWithDeletedProductField_ThrowsArgumentException() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = true, Editable = false, Printable = true, Font = "consolas", PrintSide = 0, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Black.ToArgb(), FontSize = 10, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim") } }; // Act Exception exception = null; try { var simPrintDetails = zebraDetailFactory.Populate(productFields); } catch (Exception ex) { exception = ex; } // Assert exception.Should().NotBeNull(because: "An ArgumentNullException must be thrown if the array passed to Populate() does not have any valid product fields to print."); exception.Should().BeOfType(typeof(ArgumentNullException), because: "The populate fields array does not have any valid product fields. In this case the field is set to deleted"); ((ArgumentNullException)exception).ParamName.Should().Be("productFields", because: "This is the argument that should have thrown the ArgumentNullException"); }
public static string GetFiledName(ProductField field) { switch (field) { case ProductField.CODE: return("code"); case ProductField.NAME_TOKEN: return("name.token"); case ProductField.NAME: return("name"); case ProductField.DOSAGE_FORM: return("healthcare.dosageForm"); case ProductField.DISTRIBUTION_STATUS: return("healthcare.distributionStatus"); case ProductField.UNIT: return("packaging.unit"); case ProductField.SUBSTANCE: return("healthcare.components.substances.name"); case ProductField.PRODUCER: return("producer"); default: throw new NotImplementedException(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // delete int?deleteId = WA.Parser.ToInt(Request.QueryString["delete"]); if (deleteId.HasValue) { ProductField toDelete = new ProductField(); if (toDelete.LoadByPrimaryKey(deleteId.Value)) { int productId = toDelete.ProductId.Value; toDelete.MarkAsDeleted(); toDelete.Save(); Response.Redirect(StoreUrls.AdminEditProduct(productId, "Product variant/attribute deleted")); } } PopulateListControls(); if (productField.Id.HasValue) { FillForEdit(); } } }
public void ZebraZC3_ReadandPrint() { //Zebra.Sdk.Comm.ConnectionException var printers = ZebraZC3.GetPrinterList(); using (var printer = printers[0]) { printer.Connect(); ProductField nameOnCardField = new ProductField { Deleted = false, Printable = true, X = 500, Y = 200, Value = Encoding.UTF8.GetBytes("Veneka Test Printing"), Font = "Consolas", FontColourRGB = Color.Black.ToArgb(), FontSize = 10, PrintSide = 0 }; var printDetail = printer.PrinterDetailFactory().Populate(new ProductField[] { nameOnCardField }); printer.ReadAndPrint("", printDetail, out IDeviceMagData magData); } }
// GET: Admin/ProductFields/Delete/5 public ActionResult Delete(int?id) { ProductField productField = db.ProductFields.Find(id); db.ProductFields.Remove(productField); db.SaveChanges(); return(Redirect("/Admin/ProductFields/Index/" + TempData["ID"])); }
protected string GetSearchConditionValue(ProductField field) { var cond = SearchConditions.FirstOrDefault(x => x.field == field); if (cond == null) { return(string.Empty); } return(cond.query); }
private void BindData() { int recordCount = 0; int num = 0; string strSort = " Sort ASC,AutoID desc "; this.SinGooPager1.PageSize = WebUtils.GetInt(this.drpPageSize.SelectedValue); this.Repeater1.DataSource = ProductField.GetPagerData("*", this.GetCondition(), strSort, this.SinGooPager1.PageSize, this.SinGooPager1.PageIndex, ref recordCount, ref num); this.Repeater1.DataBind(); this.SinGooPager1.RecordCount = recordCount; }
public static string GetPrefixForField(SearchCondition[] conditions, ProductField field) { if (conditions != null) { var gf = conditions.FirstOrDefault(q => q != null && q.field == field); if (gf != null) { return(gf.query); } } return(string.Empty); }
private void GenerateRadioCheckboxChoicesInList(StringBuilder html, ProductField productField, string inputType, List <ProductFieldChoice> choices, string inputName) { choices.ForEach(c => html.AppendFormat(@"<span> <input type=""{4}"" id=""{0}"" name=""{1}"" value=""{2}"" {5} /> <label for=""{0}"">{3}</label> </span>" , inputName + "-" + c.Id , inputName , c.Value , GetChoiceTextHtml(c, (widgetShowTotalProductPrice && inputType != "checkbox")) , inputType , productField.IsRequired.GetValueOrDefault() ? string.Format(@"class=""required"" title=""{0} is required""", productField.Name) : "" ) ); }
public ActionResult Create([Bind(Include = "Id,ProductId,FieldId,ENFieldValue,FAFieldValue")] ProductField productField, int?id) { if (ModelState.IsValid) { db.ProductFields.Add(productField); db.SaveChanges(); return(Redirect("/Admin/ProductFields/Index/" + id)); } ViewBag.FieldId = new SelectList(db.Fields, "Id", "ENName", "FAName", productField.FieldId); ViewBag.ProductId = new SelectList(db.Products.Where(p => p.Id == id).ToList(), "Id", "Name", productField.ProductId); return(PartialView(productField)); }
public IActionResult UpdateProductFileds(int id, string result) { char[] dash = new char[] { '-' }; string[] strResult = result.Split(dash); _store.DeleteAllProductFields(id); List <ProductFieldViewModel> models = new List <ProductFieldViewModel>(); int counter = 1; foreach (var item in strResult) { ProductFieldViewModel productField = new ProductFieldViewModel() { Id = counter, Value = item }; models.Add(productField); counter += 1; } Product product = _store.GetProduct(id); Category category = _store.GetCategory(product.CategoryId); int?categoryId = category.Parent.ParentId; List <FieldCategory> fieldCategories = _store.GetFieldCategories((int)categoryId); counter = 1; foreach (var item in fieldCategories) { ProductFieldViewModel viewModel = models.FirstOrDefault(x => x.Id == counter); ProductField productField = new ProductField() { ProductId = id, Value = viewModel.Value, FieldId = item.FieldId }; _store.AddProductField(productField); counter += 1; } return(Redirect("/Panel/ShowProducts/")); }
public static string GetFiledName(ProductField field) { switch (field) { case ProductField.CODE: return("code"); case ProductField.NAME: return("name"); default: throw new NotImplementedException(); } }
protected void lnk_Delete_Click(object sender, System.EventArgs e) { if (!base.IsAuthorizedOp(ActionType.Delete.ToString())) { base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền"); } else { int @int = WebUtils.GetInt((sender as LinkButton).CommandArgument); ProductModelInfo cacheModelById = ProductModel.GetCacheModelById(@int); if (cacheModelById == null) { base.ShowAjaxMsg(this.UpdatePanel1, "Những thông tin này không được tìm thấy, các dữ liệu không tồn tại hoặc đã bị xóa"); } else { ModelDeleteStatus modelDeleteStatus = ProductModel.Delete(@int); ModelDeleteStatus modelDeleteStatus2 = modelDeleteStatus; switch (modelDeleteStatus2) { case ModelDeleteStatus.Error: base.ShowAjaxMsg(this.UpdatePanel1, "删除模型失败"); break; case ModelDeleteStatus.ModelNotExists: base.ShowAjaxMsg(this.UpdatePanel1, "模型不存在或者已经被删除"); break; case ModelDeleteStatus.NodesRef: case ModelDeleteStatus.ContentRef: break; case ModelDeleteStatus.UserRef: base.ShowAjaxMsg(this.UpdatePanel1, "无法删除,正被产品引用"); break; default: if (modelDeleteStatus2 == ModelDeleteStatus.Success) { ProductField.DeleteByModelID(@int); this.BindData(); PageBase.log.AddEvent(base.LoginAccount.AccountName, "删除模型[" + cacheModelById.ModelName + "] thành công"); base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công"); } break; } } } }
public ProductResultSet SearchProducts(string query, int page, int perPage, int[] programmeIds, int[] excludedProgrammeIds, int[] excludedProgrammeCategoryIds, int[] feedIds, int level1CategoryId, int level2CategoryId, bool includeAdult, string lid, ProductField sort, SortOrder sortOrder) { BuyatAffiliateProductSearchParameters searchParams = new BuyatAffiliateProductSearchParameters(); searchParams.query = query; if (page != -1) { searchParams.page = page.ToString(); } if (perPage != -1) { searchParams.perpage = perPage.ToString(); } if (programmeIds != null) { searchParams.programme_ids = Implode(programmeIds, ","); } if (programmeIds != null) { searchParams.excluded_programme_ids = Implode(excludedProgrammeIds, ","); } if (programmeIds != null) { searchParams.excluded_programme_category_ids = Implode(excludedProgrammeCategoryIds, ","); } if (programmeIds != null) { searchParams.feed_ids = Implode(feedIds, ","); } if (level1CategoryId != -1) { searchParams.level1_category_id = level1CategoryId.ToString(); } if (level2CategoryId != -1) { searchParams.level2_category_id = level2CategoryId.ToString(); } searchParams.include_adult = includeAdult; searchParams.lid = lid; searchParams.sort = (BuyatAffiliateEntitiesSortType)Enum.ToObject(typeof(BuyatAffiliateEntitiesSortType), sort); searchParams.sortorder = (BuyatAffiliateEntitiesSortOrder)Enum.ToObject(typeof(BuyatAffiliateEntitiesSortOrder), sortOrder); BuyatAffiliateProductSearchResponse searchResponse = binding.buyatAffiliateProductSearch(apiKey, searchParams); return new ProductResultSet(this, searchResponse); }
protected void btn_SaveSort_Click(object sender, System.EventArgs e) { System.Collections.Generic.Dictionary <int, int> repeaterSortDict = base.GetRepeaterSortDict(this.Repeater1, "txtsort", "autoid"); if (repeaterSortDict.Count > 0) { if (ProductField.UpdateSort(repeaterSortDict)) { this.BindData(); PageBase.log.AddEvent(base.LoginAccount.AccountName, "Trường sản phẩm cập nhật [" + this.modelParent.ModelName + "] thành công"); base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công"); } else { base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thất bại"); } } }
private System.Collections.Generic.Dictionary <string, ProductFieldInfo> GetFieldDicWithValues() { System.Collections.Generic.Dictionary <string, ProductFieldInfo> dictionary = new System.Collections.Generic.Dictionary <string, ProductFieldInfo>(); foreach (RepeaterItem repeaterItem in this.rptDetail.Items) { FieldControl fieldControl = repeaterItem.FindControl("field") as FieldControl; if (fieldControl != null) { ProductFieldInfo dataById = ProductField.GetDataById(fieldControl.FieldId); if (dataById != null) { dataById.Value = fieldControl.Value; dictionary.Add(dataById.FieldName, dataById); } } } return(dictionary); }
protected void rptCustomFields_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ProductField productField = e.Item.DataItem as ProductField; Repeater rptFieldChoices = e.Item.FindControl("rptFieldChoices") as Repeater; if (productField != null && rptFieldChoices != null) { rptFieldChoices.DataSource = productField.GetChoicesInSortOrder(); rptFieldChoices.DataBind(); HtmlGenericControl liOptions = e.Item.FindControl("liOptions") as HtmlGenericControl; if (liOptions != null && rptFieldChoices.Items.Count == 0) { liOptions.Visible = false; } } } }
public void ZebraDetailFactory_PopulateWithSingleProductField_Success() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, Font = "consolas", PrintSide = 0, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Black.ToArgb(), FontSize = 10, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim") } }; // Act var simPrintDetails = zebraDetailFactory.Populate(productFields); // Assert simPrintDetails.FrontPanelText.Length.Should().Be(1, because: "Single front side text field passed in"); }
public static string GetQueryForField(SearchCondition[] conditions, ProductField field) { var retVal = ""; if (conditions != null) { var gf = conditions.FirstOrDefault(q => q != null && q.field == field); if (gf != null) { if (!gf.query.Contains("*")) { retVal += "*" + gf.query + "*"; } else { retVal += gf.query; } } } return(retVal); }
public void ZebraDetailFactory_PopulateWithBackMixedFields_BackPanelTextFieldSetCorrectly() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, Font = "consolas", PrintSide = 1, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Black.ToArgb(), FontSize = 10, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, Font = "arial", PrintSide = 1, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Red.ToArgb(), FontSize = 12, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 100, Height = 200, ProductPrintFieldTypeId = 1, X = 43, Y = 66, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 3") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 1, Width = 430, Height = 789, ProductPrintFieldTypeId = 1, X = 5, Y = 9, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 4") } }; var firstField = productFields[0]; var firstTextField = new ZebraCardTextDetail(firstField.ValueToString(), firstField.X, firstField.Y, firstField.Font, firstField.FontSize, firstField.FontColourRGB, FontStyle.Regular); var secondField = productFields[1]; var secondTextField = new ZebraCardTextDetail(secondField.ValueToString(), secondField.X, secondField.Y, secondField.Font, secondField.FontSize, secondField.FontColourRGB, FontStyle.Regular); // Act var simPrintDetails = zebraDetailFactory.Populate(productFields); // Assert simPrintDetails.BackPanelText[0].Should().BeEquivalentTo(firstTextField); simPrintDetails.BackPanelText[1].Should().BeEquivalentTo(secondTextField); }
public void PrintSimDetailFactory_PopulateWithFrontMixedFields_FrontPanelImageFieldSetCorrectly() { // Arrange var simDetailFactory = new PrintSimDetailFactory(); ProductField[] productFields = new ProductField[] { new ProductField { Deleted = false, Editable = false, Printable = true, Font = "consolas", PrintSide = 0, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Black.ToArgb(), FontSize = 10, X = 15, Y = 30, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 1") }, new ProductField { Deleted = false, Editable = false, Printable = true, Font = "arial", PrintSide = 0, ProductPrintFieldTypeId = 0, FontColourRGB = Color.Red.ToArgb(), FontSize = 12, X = 20, Y = 52, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 2") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 0, Width = 100, Height = 200, ProductPrintFieldTypeId = 1, X = 43, Y = 66, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 3") }, new ProductField { Deleted = false, Editable = false, Printable = true, PrintSide = 0, Width = 430, Height = 789, ProductPrintFieldTypeId = 1, X = 5, Y = 9, Value = Encoding.UTF8.GetBytes("Hello From Print Sim field 4") } }; var firstField = productFields[2]; var firstImageField = new PrintSimCardImageDetail(firstField.Value, firstField.X, firstField.Y, firstField.Width, firstField.Height); var secondField = productFields[3]; var secondImageField = new PrintSimCardImageDetail(secondField.Value, secondField.X, secondField.Y, secondField.Width, secondField.Height); // Act var simPrintDetails = simDetailFactory.Populate(productFields); // Assert simPrintDetails.FrontPanelImages[0].Should().BeEquivalentTo(firstImageField); simPrintDetails.FrontPanelImages[1].Should().BeEquivalentTo(secondImageField); }
public void ZebraDetailFactory_PopulateWithEmptyProductFieldArray_ThrowsArgumentException() { // Arrange var zebraDetailFactory = new ZebraDetailFactory(); ProductField[] productFields = new ProductField[0]; // Act Exception exception = null; try { var simPrintDetails = zebraDetailFactory.Populate(productFields); } catch (Exception ex) { exception = ex; } // Assert exception.Should().NotBeNull(because: "An ArgumentNullException must be thrown if an empty array is passed to Populate(). Calling code should make sure there is something to populate."); exception.Should().BeOfType(typeof(ArgumentNullException), because: "The populate fields argument is null or empty. Must return correct expection type to indicate this"); ((ArgumentNullException)exception).ParamName.Should().Be("productFields", because: "This is the argument that should have thrown the ArgumentNullException"); }
public ProductResultSet SearchProducts(string query, int page, int perPage, string lid, ProductField sort, SortOrder sortOrder) { return SearchProducts(query, page, perPage, null, null, null, null, -1, -1, false, lid, sort, sortOrder); }