Ejemplo n.º 1
0
        public void TestBuildInput_NoIdentifier_Compression()
        {
            ICompressor compressor = new GZipCompressor();
            Image       img        = _createTestImage();
            JobInput    i          = new JobInput(img);

            i.Compressor = compressor;
            JobBuilderProcess p       = new JobBuilderProcess();
            XElement          element = p.BuildInput(i);

            Assert.AreEqual("input", element.Name);
            Assert.IsNull(element.Attribute("identifier"));

            Assert.IsNotNull(element.Attribute("compressor"));
            Assert.AreEqual("gzip", element.Attribute("compressor").Value.ToLower());

            XNode child = element.FirstNode;

            Assert.IsTrue(child.NodeType == System.Xml.XmlNodeType.CDATA);

            XCData data          = (XCData)child;
            string providedImage = data.Value;
            string expectedImage = System.Text.Encoding.Default.GetString(CompressionAssistant.Compress(img, compressor));

            Assert.AreEqual(expectedImage, providedImage);
        }
Ejemplo n.º 2
0
        public void TestBuildInput_Identifier_NoCompression()
        {
            object   identifier = "Test";
            Image    img        = _createTestImage();
            JobInput i          = new JobInput(img);

            i.Identifier = identifier;
            JobBuilderProcess p       = new JobBuilderProcess();
            XElement          element = p.BuildInput(i);

            Assert.AreEqual("input", element.Name);

            Assert.IsNotNull(element.Attribute("identifier"));
            Assert.AreEqual(identifier, element.Attribute("identifier").Value);

            XNode child = element.FirstNode;

            Assert.IsTrue(child.NodeType == System.Xml.XmlNodeType.CDATA);

            XCData data          = (XCData)child;
            string providedImage = data.Value;
            string expectedImage = System.Text.Encoding.Default.GetString(CompressionAssistant.ImageToBytes(img));

            Assert.AreEqual(expectedImage, providedImage);
        }