Example #1
0
        public void WebSite_Image_Can_Dynamically_Change_Height_Of_Images()
        {
            _WebSite.AttachSiteToServer(_WebServer.Object);
            var pathAndFile = "/Images/Hght-11/TestSquare.png";

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreEqual(9, siteImage.Width);
                Assert.AreEqual(11, siteImage.Height);

                for (var x = 0; x < 9; ++x)
                {
                    foreach (var y in new int[] { 0, 10 })
                    {
                        Assert.AreEqual(_Transparent, siteImage.GetPixel(x, y), "x = {0}, y = {1}", x, y);
                    }

                    Assert.AreEqual(_White, siteImage.GetPixel(0, 1));
                    Assert.AreEqual(_Black, siteImage.GetPixel(3, 1));
                    Assert.AreEqual(_Red, siteImage.GetPixel(0, 4));
                    Assert.AreEqual(_Green, siteImage.GetPixel(8, 4));
                    Assert.AreEqual(_Blue, siteImage.GetPixel(3, 9));
                }
            }
        }
Example #2
0
        public void WebSite_Image_Can_Dynamically_Rotate_Images()
        {
            foreach (var rotateDegrees in new int[] { 0, 90, 180, 270 })
            {
                TestCleanup();
                TestInitialise();
                _WebSite.AttachSiteToServer(_WebServer.Object);

                var pathAndFile = String.Format("/Images/Rotate-{0}/TestSquare.png", rotateDegrees);
                _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

                using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                    Assert.AreEqual(9, siteImage.Width);
                    Assert.AreEqual(9, siteImage.Height);

                    // Determine the colours we expect to see at the 12 o'clock, 3 o'clock, 6 o'clock and 9 o'clock positions
                    Color p12 = _White, p3 = _White, p6 = _White, p9 = _White;
                    switch (rotateDegrees)
                    {
                    case 0:     p12 = _Black;  p3 = _Green;   p6 = _Blue;    p9 = _Red;     break;

                    case 90:    p12 = _Red;    p3 = _Black;   p6 = _Green;   p9 = _Blue;    break;

                    case 180:   p12 = _Blue;   p3 = _Red;     p6 = _Black;   p9 = _Green;   break;

                    case 270:   p12 = _Green;  p3 = _Blue;    p6 = _Red;     p9 = _Black;   break;
                    }

                    Assert.AreEqual(p12, siteImage.GetPixel(4, 1), rotateDegrees.ToString());
                    Assert.AreEqual(p3, siteImage.GetPixel(7, 4), rotateDegrees.ToString());
                    Assert.AreEqual(p6, siteImage.GetPixel(4, 7), rotateDegrees.ToString());
                    Assert.AreEqual(p9, siteImage.GetPixel(1, 4), rotateDegrees.ToString());
                }
            }
        }
Example #3
0
        private void Do_Image_Resizes_Small_Logos_To_Fit_Standard_Size(bool isOpFlag)
        {
            if (isOpFlag)
            {
                _Configuration.BaseStationSettings.OperatorFlagsFolder = TestContext.TestDeploymentDir;
            }
            else
            {
                _Configuration.BaseStationSettings.SilhouettesFolder = TestContext.TestDeploymentDir;
            }
            _WebSite.AttachSiteToServer(_WebServer.Object);

            var pathAndFile = String.Format("/Images/File-TestSquare/{0}.png", isOpFlag ? "OpFlag" : "Type");

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreEqual(85, siteImage.Width);
                Assert.AreEqual(20, siteImage.Height);

                // Should have placed the small image (TestSquare is 9x9) in the centre as per rules for WDTH and HGHT
                Assert.AreEqual(_Transparent, siteImage.GetPixel(0, 0));
                Assert.AreEqual(_White, siteImage.GetPixel(39, 7));
                Assert.AreEqual(_Black, siteImage.GetPixel(42, 7));
            }
        }
Example #4
0
        public void WebSite_Image_Correct_Image_Is_Rendered()
        {
            ExcelWorksheetData worksheet   = new ExcelWorksheetData(TestContext);
            string             pathAndFile = worksheet.String("UrlPath");

            _WebSite.AttachSiteToServer(_WebServer.Object);

            var args = RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false);

            _WebServer.Raise(m => m.RequestReceived += null, args);
            Assert.AreEqual(true, args.Handled);

            byte[] content     = _OutputStream.ToArray();
            var    md5Checksum = new StringBuilder();

            using (var md5 = MD5.Create()) {
                foreach (var b in md5.ComputeHash(content))
                {
                    md5Checksum.AppendFormat("{0:X2}", b);
                }
            }

            Assert.AreEqual(worksheet.String("MimeType"), _Response.Object.MimeType);
            Assert.AreEqual(worksheet.Int("Length"), content.Length);
            Assert.AreEqual(worksheet.String("MD5"), md5Checksum.ToString(), true);
        }
Example #5
0
        public void WebSite_Image_Can_Dynamically_Add_Text()
        {
            _Configuration.BaseStationSettings.PicturesFolder = TestContext.TestDeploymentDir;
            _WebSite.AttachSiteToServer(_WebServer.Object);

            // This is tricky to test as we can't really reliably compare images that have had text drawn on them. I think the images will be
            // slightly different between systems. Instead we just check that something changes about the image.
            for (var lineNumber = 0; lineNumber < 12; ++lineNumber)
            {
                ConfigurePictureManagerForPathAndFile(TestContext.TestDeploymentDir, "TestSquare.png");
                var    expectDifference = lineNumber >= 1 && lineNumber <= 9;
                string message          = lineNumber.ToString();

                CreateMonochromeImage("TextImageTest.png", 50, 50, Brushes.Black);
                _OutputStream.SetLength(0);

                var pathAndFile = String.Format("/Images/PL{0}-!/File-TestSquare/Size-Full/Picture.png", lineNumber);
                _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

                using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                    Assert.AreEqual(9, siteImage.Width, message);
                    Assert.AreEqual(9, siteImage.Height, message);

                    if (expectDifference)
                    {
                        AssertImagesAreNotIdentical("TestSquare.png", siteImage, message);
                    }
                    else
                    {
                        AssertImagesAreIdentical("TestSquare.png", siteImage, message);
                    }
                }
            }
        }
Example #6
0
        private void Do_Image_Resizes_Large_Logos_To_Fit_Standard_Size(bool isOpFlag)
        {
            if (isOpFlag)
            {
                _Configuration.BaseStationSettings.OperatorFlagsFolder = TestContext.TestDeploymentDir;
            }
            else
            {
                _Configuration.BaseStationSettings.SilhouettesFolder = TestContext.TestDeploymentDir;
            }
            _WebSite.AttachSiteToServer(_WebServer.Object);

            var pathAndFile = String.Format("/Images/File-OversizedLogo/{0}.png", isOpFlag ? "OpFlag" : "Type");

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreEqual(85, siteImage.Width);
                Assert.AreEqual(20, siteImage.Height);

                // Should have placed the large image in the centre - the image is 87x22 whereas the standard size is 85x20 so by centreing
                // it we should have cropped a 1 pixel border off the image, which leaves a black pixel in each corner
                Assert.AreEqual(_Black, siteImage.GetPixel(0, 0));
                Assert.AreEqual(_White, siteImage.GetPixel(1, 0));
                Assert.AreEqual(_Black, siteImage.GetPixel(84, 0));
                Assert.AreEqual(_Black, siteImage.GetPixel(0, 19));
                Assert.AreEqual(_Black, siteImage.GetPixel(84, 19));
            }
        }
Example #7
0
        private RequestReceivedEventArgs SendRequest(string pathAndFile, bool isInternetClient)
        {
            var args = RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, isInternetClient);

            _WebServer.Raise(m => m.RequestReceived += null, args);

            return(args);
        }
Example #8
0
        public void WebSite_Image_Does_Not_Compress_Images()
        {
            _WebSite.AttachSiteToServer(_WebServer.Object);
            var pathAndFile = "/Images/Hght-15/CenX-4/Alt-/TestSquare.png";

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            _Response.Verify(r => r.EnableCompression(_Request.Object), Times.Never());
        }
Example #9
0
        public void WebSite_Image_Calls_Aircraft_Manager_Correctly_When_Icao_Is_Missing()
        {
            _WebSite.AttachSiteToServer(_WebServer.Object);

            string pathAndFile = "/Images/Size-Full/File-G-ABCD /Picture.png";

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            _AircraftPictureManager.Verify(m => m.LoadPicture(_DirectoryCache.Object, null, "G-ABCD"), Times.Once());
        }
Example #10
0
        public void WebSite_Image_Can_Dynamically_Add_Altitude_Stalk()
        {
            _WebSite.AttachSiteToServer(_WebServer.Object);
            var pathAndFile = "/Images/Hght-15/CenX-4/Alt-/TestSquare.png";

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                AssertImagesAreIdentical("AltitudeImageTest-01.png", siteImage);
            }
        }
Example #11
0
        public void WebSite_Image_Does_Not_Throw_Exception_When_Model_Icao_Contains_Invalid_Characters()
        {
            _Configuration.BaseStationSettings.SilhouettesFolder = TestContext.TestDeploymentDir;
            _WebSite.AttachSiteToServer(_WebServer.Object);

            foreach (var badChar in Path.GetInvalidFileNameChars().Concat(Path.GetInvalidPathChars()))
            {
                var fileName    = "BA" + badChar;
                var pathAndFile = String.Format("/Images/File-{0}/Type.png", HttpUtility.UrlEncode(fileName));
                _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));
            }
        }
Example #12
0
        public void WebSite_Image_Copes_If_Aircraft_Picture_Does_Not_Exist()
        {
            _Configuration.BaseStationSettings.PicturesFolder = TestContext.TestDeploymentDir;
            _WebSite.AttachSiteToServer(_WebServer.Object);

            _AircraftPictureManager.Setup(p => p.LoadPicture(_DirectoryCache.Object, It.IsAny <string>(), It.IsAny <string>())).Returns((Image)null);

            string pathAndFile = "/Images/Size-Full/File-G-ABCD 112233/Picture.png";

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            Assert.AreEqual((HttpStatusCode)0, _Response.Object.StatusCode);
            Assert.AreEqual(0, _Response.Object.ContentLength);
            Assert.AreEqual(0, _Response.Object.OutputStream.Length);
        }
Example #13
0
        public void WebSite_Image_Can_Render_Aircraft_Full_Sized_Picture()
        {
            _Configuration.BaseStationSettings.PicturesFolder = TestContext.TestDeploymentDir;
            ConfigurePictureManagerForPathAndFile(TestContext.TestDeploymentDir, "Picture-700x400.png");

            _WebSite.AttachSiteToServer(_WebServer.Object);

            string pathAndFile = "/Images/Size-Full/File-Picture-700x400/Picture.png";

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                AssertImagesAreIdentical("Picture-700x400.png", siteImage);
            }
        }
Example #14
0
        public void WebSite_Image_Can_Display_Aircraft_Picture_Correctly()
        {
            _WebSite.AttachSiteToServer(_WebServer.Object);

            CreateMonochromeImage("AnAircraftPicture.png", 10, 10, Brushes.White);
            ConfigurePictureManagerForPathAndFile(TestContext.TestDeploymentDir, "AnAircraftPicture.png", "112233", "G-ABCD");

            string pathAndFile = "/Images/Size-Full/File-G-ABCD 112233/Picture.png";

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                AssertImageIsMonochrome(siteImage, _White, 10, 10);
            }
        }
Example #15
0
        public void WebSite_Image_Picks_Up_Configuration_Changes_For_Internet_Viewing_Of_Pictures()
        {
            _Configuration.BaseStationSettings.PicturesFolder = TestContext.TestDeploymentDir;
            ConfigurePictureManagerForPathAndFile(TestContext.TestDeploymentDir, "TestSquare.png");

            _WebSite.AttachSiteToServer(_WebServer.Object);

            foreach (var size in new string[] { "DETAIL", "FULL", "LIST", "IPADDETAIL", "IPHONEDETAIL" })
            {
                ConfigurePictureManagerForPathAndFile(TestContext.TestDeploymentDir, "TestSquare.png");
                string pathAndFile = String.Format("/Images/Size-{0}/File-TestSquare/Picture.png", size);

                _OutputStream.SetLength(0);
                _Response = new Mock <IResponse>()
                {
                    DefaultValue = DefaultValue.Mock
                }.SetupAllProperties();
                _Response.Setup(m => m.OutputStream).Returns(_OutputStream);

                _Configuration.InternetClientSettings.CanShowPictures    = true;
                _ConfigurationStorage.Raise(m => m.ConfigurationChanged += null, EventArgs.Empty);

                _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, true));

                Assert.AreEqual(HttpStatusCode.OK, _Response.Object.StatusCode, size);
                using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                    Assert.AreNotEqual(0, siteImage.Width, size);
                }

                _Configuration.InternetClientSettings.CanShowPictures    = false;
                _ConfigurationStorage.Raise(m => m.ConfigurationChanged += null, EventArgs.Empty);

                _OutputStream.SetLength(0);
                _Response = new Mock <IResponse>()
                {
                    DefaultValue = DefaultValue.Mock
                }.SetupAllProperties();
                _Response.Setup(m => m.OutputStream).Returns(_OutputStream);

                _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, true));

                Assert.AreEqual((HttpStatusCode)0, _Response.Object.StatusCode, size);   // WebServer should eventually send 403 but we're not responsible for doing that
                Assert.AreEqual(0, _Response.Object.ContentLength, size);
                Assert.AreEqual(0, _OutputStream.Length, size);
            }
        }
Example #16
0
        public void WebSite_Image_Can_Return_IPhone_Splash_Screen()
        {
            // The content of this is built dynamically and while we could compare checksums I suspect that over different machines you'd get
            // slightly different results. So this test just checks that if you ask for a splash screen then you get something back that's the
            // right size and has what looks to be the correct colour background.
            _Configuration.BaseStationSettings.PicturesFolder = TestContext.TestDeploymentDir;
            _WebSite.AttachSiteToServer(_WebServer.Object);

            string pathAndFile = "/Images/IPhoneSplash.png";

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreEqual(320, siteImage.Width);
                Assert.AreEqual(460, siteImage.Height);
                Assert.AreEqual(_Black, siteImage.GetPixel(10, 10));
            }
        }
Example #17
0
        public void WebSite_Image_Can_Return_IPad_Splash_Screen_Via_Explicit_Instruction()
        {
            // See notes on iPhone version

            _Configuration.BaseStationSettings.PicturesFolder = TestContext.TestDeploymentDir;
            _WebSite.AttachSiteToServer(_WebServer.Object);

            string pathAndFile = "/Images/File-IPad/IPhoneSplash.png";
            var    args        = RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false);

            _WebServer.Raise(m => m.RequestReceived += null, args);

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreEqual(768, siteImage.Width);
                Assert.AreEqual(1004, siteImage.Height);
                Assert.AreEqual(_Black, siteImage.GetPixel(10, 10));
            }
        }
Example #18
0
        public void WebSite_Image_Renders_Pictures_At_Correct_Size()
        {
            var worksheet = new ExcelWorksheetData(TestContext);

            CreateMonochromeImage("ImageRenderSize.png", worksheet.Int("OriginalWidth"), worksheet.Int("OriginalHeight"), Brushes.Red);
            ConfigurePictureManagerForPathAndFile(TestContext.TestDeploymentDir, "ImageRenderSize.png");

            _Configuration.BaseStationSettings.PicturesFolder = TestContext.TestDeploymentDir;
            _WebSite.AttachSiteToServer(_WebServer.Object);

            string pathAndFile = String.Format("/Images/Size-{0}/File-ImageRenderSize/Picture.png", worksheet.String("Size"));

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                AssertImageIsMonochrome(siteImage, _Red, worksheet.Int("NewWidth"), worksheet.Int("NewHeight"));
            }
        }
Example #19
0
        private void Do_Image_Can_Serve_Alternative_Logo(bool isOpFlag)
        {
            if (isOpFlag)
            {
                _Configuration.BaseStationSettings.OperatorFlagsFolder = TestContext.TestDeploymentDir;
            }
            else
            {
                _Configuration.BaseStationSettings.SilhouettesFolder = TestContext.TestDeploymentDir;
            }
            _WebSite.AttachSiteToServer(_WebServer.Object);

            var pathAndFile = String.Format("/Images/File-DOESNOTEXIST|DLH/{0}.png", isOpFlag ? "OpFlag" : "Type");

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                AssertImagesAreIdentical("DLH.bmp", siteImage);
            }
        }
Example #20
0
        public void WebSite_Image_Ignores_Requests_For_Pictures_From_Internet_When_Prohibited()
        {
            _Configuration.BaseStationSettings.PicturesFolder = TestContext.TestDeploymentDir;
            ConfigurePictureManagerForPathAndFile(TestContext.TestDeploymentDir, "TestSquare.png");

            _WebSite.AttachSiteToServer(_WebServer.Object);

            foreach (var size in new string[] { "DETAIL", "FULL", "LIST", "IPADDETAIL", "IPHONEDETAIL" })
            {
                string pathAndFile = String.Format("/Images/Size-{0}/File-TestSquare/Picture.png", size);

                _Configuration.InternetClientSettings.CanShowPictures = false;

                _OutputStream.SetLength(0);
                _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, true));

                Assert.AreEqual((HttpStatusCode)0, _Response.Object.StatusCode, size);   // WebServer should eventually send 403 but we're not responsible for doing that
                Assert.AreEqual(0, _Response.Object.ContentLength, size);
                Assert.AreEqual(0, _OutputStream.Length, size);
            }
        }
Example #21
0
        public void WebSite_Image_Will_Not_Dynamically_Add_Text_If_Configuration_Prohibits_It()
        {
            _WebSite.AttachSiteToServer(_WebServer.Object);

            // Get a blank image to start with
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, "/Images/Hght-200/Wdth-60/Airplane.png", false));
            byte[] blankImage = _OutputStream.ToArray();

            // Ask for the same image from the Internet but with a line of text
            _OutputStream.SetLength(0);
            _Configuration.InternetClientSettings.CanShowPinText     = true;
            _ConfigurationStorage.Raise(c => c.ConfigurationChanged += null, EventArgs.Empty);
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, "/Images/PL1-X/Hght-200/Wdth-60/Airplane.png", true));
            byte[] internetWithText = _OutputStream.ToArray();
            Assert.IsFalse(blankImage.SequenceEqual(internetWithText));

            // Ask for same image with text from the Internet when the configuration prohibits it
            _OutputStream.SetLength(0);
            _Configuration.InternetClientSettings.CanShowPinText     = false;
            _ConfigurationStorage.Raise(c => c.ConfigurationChanged += null, EventArgs.Empty);
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, "/Images/PL1-X/Hght-200/Wdth-60/Airplane.png", true));
            byte[] internetWithoutText = _OutputStream.ToArray();
            Assert.IsTrue(blankImage.SequenceEqual(internetWithoutText));

            // Ask for the same image from the LAN but with a line of text
            _OutputStream.SetLength(0);
            _Configuration.InternetClientSettings.CanShowPinText     = true;
            _ConfigurationStorage.Raise(c => c.ConfigurationChanged += null, EventArgs.Empty);
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, "/Images/PL1-X/Hght-200/Wdth-60/Airplane.png", false));
            byte[] lanWithText = _OutputStream.ToArray();
            Assert.IsFalse(blankImage.SequenceEqual(lanWithText));

            // Ask for same image with text from the LAN when the configuration prohibits it
            _OutputStream.SetLength(0);
            _Configuration.InternetClientSettings.CanShowPinText     = false;
            _ConfigurationStorage.Raise(c => c.ConfigurationChanged += null, EventArgs.Empty);
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, "/Images/PL1-X/Hght-200/Wdth-60/Airplane.png", false));
            byte[] lanWithoutText = _OutputStream.ToArray();
            Assert.IsFalse(blankImage.SequenceEqual(lanWithoutText));
        }
Example #22
0
        private void Do_Image_Returns_Blank_Image_If_Logo_File_Not_Found(bool isOpFlag)
        {
            if (isOpFlag)
            {
                _Configuration.BaseStationSettings.OperatorFlagsFolder = TestContext.TestDeploymentDir;
            }
            else
            {
                _Configuration.BaseStationSettings.SilhouettesFolder = TestContext.TestDeploymentDir;
            }
            _WebSite.AttachSiteToServer(_WebServer.Object);

            var pathAndFile = String.Format("/Images/File-DoesNotExist/{0}.png", isOpFlag ? "OpFlag" : "Type");

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreEqual(85, siteImage.Width);
                Assert.AreEqual(20, siteImage.Height);
                AssertImageIsMonochrome(siteImage, _Transparent);
            }
        }
Example #23
0
        public void WebSite_Image_Can_Create_Blank_Images_Dynamically()
        {
            ExcelWorksheetData worksheet = new ExcelWorksheetData(TestContext);

            _WebSite.AttachSiteToServer(_WebServer.Object);

            var args = RequestReceivedEventArgsHelper.Create(_Request, _Response, worksheet.String("PathAndFile"), false);

            _WebServer.Raise(m => m.RequestReceived += null, args);

            if (worksheet.String("Width") == null)
            {
                Assert.AreEqual(false, args.Handled);
                Assert.AreEqual(0, _OutputStream.Length);
                Assert.AreEqual(0, _Response.Object.ContentLength);
            }
            else
            {
                using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                    AssertImageIsMonochrome(siteImage, _Transparent, worksheet.Int("Width"), worksheet.Int("Height"));
                }
            }
        }
Example #24
0
        private void Do_Image_Render_Logo_Picks_Up_Changes_In_Configuration_Folder(bool isOpFlag)
        {
            if (isOpFlag)
            {
                _Configuration.BaseStationSettings.OperatorFlagsFolder = "c:\\Whatever, this don't exist, whatever";
            }
            else
            {
                _Configuration.BaseStationSettings.SilhouettesFolder = "c:\\Whatever, this don't exist, whatever";
            }
            _WebSite.AttachSiteToServer(_WebServer.Object);

            var pathAndFile = String.Format("/Images/File-DLH/{0}.png", isOpFlag ? "OpFlag" : "Type");

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));

            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                AssertImageIsMonochrome(siteImage, _Transparent);
            }

            _OutputStream.SetLength(0);

            if (isOpFlag)
            {
                _Configuration.BaseStationSettings.OperatorFlagsFolder = TestContext.TestDeploymentDir;
            }
            else
            {
                _Configuration.BaseStationSettings.SilhouettesFolder = TestContext.TestDeploymentDir;
            }
            _ConfigurationStorage.Raise(m => m.ConfigurationChanged += null, EventArgs.Empty);

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));
            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                AssertImagesAreIdentical("DLH.bmp", siteImage);
            }
        }
Example #25
0
        private void Do_Image_Returns_Blank_Image_If_Attempt_Made_To_Move_Out_Of_Logo_Folder(bool isOpFlag)
        {
            if (isOpFlag)
            {
                _Configuration.BaseStationSettings.OperatorFlagsFolder = Path.Combine(TestContext.TestDeploymentDir, "SubFolder");
            }
            else
            {
                _Configuration.BaseStationSettings.SilhouettesFolder = Path.Combine(TestContext.TestDeploymentDir, "SubFolder");
            }
            _WebSite.AttachSiteToServer(_WebServer.Object);

            var pathAndFile = String.Format("/Images/File-VIR/{0}.png", isOpFlag ? "OpFlag" : "Type");

            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));
            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                AssertImagesAreIdentical("SubFolder\\Vir.bmp", siteImage);
            }

            _OutputStream.SetLength(0);
            pathAndFile = String.Format("/Images/File-..\\DLH/{0}.png", isOpFlag ? "OpFlag" : "Type");
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));
            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreNotEqual(0, siteImage.Width);
                AssertImageIsMonochrome(siteImage, _Transparent);
            }

            _OutputStream.SetLength(0);
            pathAndFile = String.Format("/Images/File-..%5CDLH/{0}.png", isOpFlag ? "OpFlag" : "Type");
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));
            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreNotEqual(0, siteImage.Width);
                AssertImageIsMonochrome(siteImage, _Transparent);
            }

            if (isOpFlag)
            {
                _Configuration.BaseStationSettings.OperatorFlagsFolder = TestContext.TestDeploymentDir;
            }
            else
            {
                _Configuration.BaseStationSettings.SilhouettesFolder = TestContext.TestDeploymentDir;
            }
            _ConfigurationStorage.Raise(m => m.ConfigurationChanged += null, EventArgs.Empty);

            _OutputStream.SetLength(0);
            pathAndFile = String.Format("/Images/File-SubFolder\\VIR/{0}.png", isOpFlag ? "OpFlag" : "Type");
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));
            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreNotEqual(0, siteImage.Width);
                AssertImageIsMonochrome(siteImage, _Transparent);
            }

            _OutputStream.SetLength(0);
            pathAndFile = String.Format("/Images/File-SubFolder%5CVIR/{0}.png", isOpFlag ? "OpFlag" : "Type");
            _WebServer.Raise(m => m.RequestReceived += null, RequestReceivedEventArgsHelper.Create(_Request, _Response, pathAndFile, false));
            using (var siteImage = (Bitmap)Bitmap.FromStream(_OutputStream)) {
                Assert.AreNotEqual(0, siteImage.Width);
                AssertImageIsMonochrome(siteImage, _Transparent);
            }
        }