Beispiel #1
0
        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 ZebraCardTextDetail_ConstructorValuesSetCorrectly()
        {
            // Arrange


            // Act
            var textDetail = new ZebraCardTextDetail("TextArg", 12, 14, "fontArg", 10, 123, FontStyle.Regular);

            // Assert
            textDetail.Text.Should().Be("TextArg", because: "Property must match argument passed in constructor");
            textDetail.X.Should().Be(12, because: "Property must match argument passed in constructor");
            textDetail.Y.Should().Be(14, because: "Property must match argument passed in constructor");
            textDetail.Font.Should().Be("fontArg", because: "Property must match argument passed in constructor");
            textDetail.FontSize.Should().Be(10, because: "Property must match argument passed in constructor");
            textDetail.FontColourARGB.Should().Be(123, because: "Property must match argument passed in constructor");
            textDetail.FontType.Should().Be(FontStyle.Regular, because: "Property must match argument passed in constructor");
        }
        public void ZebraCardTextDetail_Constructor_Font_NullArgumentException()
        {
            // Arrange
            Exception receivedException = null;

            // Act
            try
            {
                var textDetail = new ZebraCardTextDetail("TextArg", 12, 14, null, 10, 123, FontStyle.Regular);
            }
            catch (Exception ex)
            {
                receivedException = ex;
            }

            // Assert
            receivedException.Should().NotBeNull(because: "ArgumentNullException must be thrown on null font argument");
            receivedException.Should().BeOfType(typeof(ArgumentNullException));
            ((ArgumentNullException)receivedException).ParamName.Should().Be("font");
        }
Beispiel #4
0
        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);
        }