Exemple #1
0
        private static dynamic CreateImage(string rotation)
        {
            dynamic imageItem = new DynamicWrapper();

            imageItem.Image               = new DynamicWrapper();
            imageItem.Image.Size          = new DynamicWrapper();
            imageItem.Image.Size.Width    = Resources.Image.Width / 3;
            imageItem.Image.Size.Height   = Resources.Image.Height / 3;
            imageItem.Image.Size.SizeUnit = "Px";
            imageItem.Image.Data          = ImageTestHelper.BitmapToBase64(Resources.Image);
            imageItem.Image.Rotation      = rotation;

            return(imageItem);
        }
        public void ShouldApplyImageData()
        {
            // Given
            var image = Resources.ImageRotate0;
            dynamic elementMetadata = new DynamicWrapper();
            elementMetadata.Data = ImageTestHelper.BitmapToBase64(image);

            // When
            PrintElementImage element = BuildTestHelper.BuildImage(elementMetadata);

            // Then
            Assert.IsNotNull(element);
            Assert.IsInstanceOf<PrintElementImage>(element);
            Assert.IsNull(element.Size);
            ImageTestHelper.AssertImagesAreEqual(image, element);
        }
        public void ShouldApplyImageDataFromSource()
        {
            // Given
            var image = Resources.ImageRotate0;
            dynamic elementMetadata = new DynamicWrapper();
            elementMetadata.Source = "$";

            // When
            var element = BuildTestHelper.BuildImage((object) elementMetadata,
                c => { c.PrintViewSource = ImageTestHelper.BitmapToBase64(image); });

            // Then
            Assert.IsNotNull(element);
            Assert.IsNull(element.Size);
            ImageTestHelper.AssertImagesAreEqual(image, element);
        }
        public void ShouldApplyRotation180()
        {
            // Given
            var original = Resources.ImageRotate0;
            var expected = Resources.ImageRotate180;
            dynamic elementMetadata = new DynamicWrapper();
            elementMetadata.Data = ImageTestHelper.BitmapToBase64(original);
            elementMetadata.Rotation = "Rotate180";

            // When
            PrintElementImage element = BuildTestHelper.BuildImage(elementMetadata);

            // Then
            Assert.IsNotNull(element);
            Assert.IsNull(element.Size);
            ImageTestHelper.AssertImagesAreEqual(expected, element);
        }
        public void ShouldApplySize()
        {
            // Given
            var image = Resources.ImageRotate0;
            dynamic elementMetadata = new DynamicWrapper();
            elementMetadata.Size = new DynamicWrapper();
            elementMetadata.Size.Width = 2*image.Width;
            elementMetadata.Size.Height = 2*image.Height;
            elementMetadata.Size.SizeUnit = "Px";
            elementMetadata.Data = ImageTestHelper.BitmapToBase64(image);

            // When
            PrintElementImage element = BuildTestHelper.BuildImage(elementMetadata);

            // Then
            Assert.IsNotNull(element);
            Assert.AreEqual(2*image.Width, element.Size.Width, 0.1);
            Assert.AreEqual(2*image.Height, element.Size.Height, 0.1);
        }