Exemplo n.º 1
0
        public void Can_Retrieve_Clipart_Image_Data()
        {
            // Arrange - create a ClipartTemplate with image data
            ClipartTemplate clipartTemplate = new ClipartTemplate
            {
                Id    = 1,
                Name  = "ClipartTemplate1",
                Image = new byte[] { }
            };

            // Arrange - create the mock repository
            Mock <IRepository <ClipartTemplate> > mock = new Mock <IRepository <ClipartTemplate> >();

            mock.Setup(m => m.Get(1)).Returns(clipartTemplate);

            // Arrange - create the controller
            ClipartTemplateController target = new ClipartTemplateController(mock.Object);

            // Act - call the Image method
            HttpResponseMessage result = target.Image(1);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.Content.Headers.ContentType.MediaType, "image/png");
        }
Exemplo n.º 2
0
        public void Cannot_Retrieve_ClipartImage_Data_For_Invalid_ID()
        {
            // Arrange - create a ClipartTemplate with image data
            ClipartTemplate clipartTemplate = new ClipartTemplate
            {
                Id    = 1,
                Name  = "ClipartTemplate2",
                Image = new byte[] { }
            };

            // Arrange - create the mock repository
            Mock <IRepository <ClipartTemplate> > mock = new Mock <IRepository <ClipartTemplate> >();

            mock.Setup(m => m.Get(1)).Returns(clipartTemplate);

            // Arrange - create the controller
            ClipartTemplateController target = new ClipartTemplateController(mock.Object);

            // Act - call the Image method
            HttpResponseMessage result = target.Image(100);

            // Assert
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.StatusCode, HttpStatusCode.BadRequest);
        }
        private void tsbtnTemplateEdit_Click(object sender, EventArgs e)
        {
            TemplateForm frm = new TemplateForm();

            int selectedClipartTemplate = (int)lvCliparts.SelectedItems[0].Tag;

            ClipartTemplate template = _clipartTemplateRepository.Get(selectedClipartTemplate);

            template.Font = fontList.Find(f => f.Id == template.FontId);
            frm.Template  = template;
            frm.Fonts     = fontList;

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                template.Font = null;
                _clipartTemplateRepository.Save();

                imageList.Images[lvCliparts.SelectedItems[0].ImageIndex] = Utils.ByteArrayToImage(template.Image);
                lvCliparts.SelectedItems[0].Selected = true;
            }
            else
            {
                template.Font = null;
                _clipartTemplateRepository.SetStateUnchanged(template);
            }

            lvCliparts.Select();

            frm.Dispose();
        }
        private void tsbtnClipartTemplateAdd_Click(object sender, EventArgs e)
        {
            TemplateForm frm = new TemplateForm();

            ClipartTemplate template = new ClipartTemplate()
            {
                EffectType         = 1,
                Name               = "A",
                Text               = "A",
                TextColor1         = Color.Red.ToArgb(),
                TextColor2         = Color.Tomato.ToArgb(),
                TextGradientEnable = true,
                OutlineColor1      = Color.Blue.ToArgb(),
                OutlineThickness1  = 1,
                OutlineColor2      = Color.Yellow.ToArgb(),
                OutlineThickness2  = 1,
                ShadowEnable       = true,
                ShadowColor        = Color.Black.ToArgb(),
                ShadowThickness    = 1,
                ShadowOffsetX      = 2,
                ShadowOffsetY      = 2,
                FontId             = fontList[0].Id,
                Font               = fontList[0], //ToDo
                ClipartGalleryId   = selectedClipartGalleryId
            };

            frm.Template = template;
            frm.Fonts    = fontList;

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                template.Font = null;

                _clipartTemplateRepository.Add(template);
                _clipartTemplateRepository.Save();

                imageList.Images.Add(Utils.ByteArrayToImage(template.Image));

                ListViewItem item = new ListViewItem();

                item.ImageIndex = imageList.Images.Count - 1;
                item.Text       = template.Name;
                item.Tag        = template.Id;

                lvCliparts.Items.Add(item);

                item.Selected = true;
            }

            lvCliparts.Select();

            frm.Dispose();
        }
Exemplo n.º 5
0
        public void Cannot_Retrieve_ClipartImage_Data_For_Invalid_ID()
        {
            // Arrange - create a ClipartTemplate with image data
            ClipartTemplate clipartTemplate = new ClipartTemplate
            {
                Id = 1,
                Name = "ClipartTemplate2",
                Image = new byte[] { }
            };

            // Arrange - create the mock repository
            Mock<IRepository<ClipartTemplate>> mock = new Mock<IRepository<ClipartTemplate>>();
            mock.Setup(m => m.Get(1)).Returns(clipartTemplate);

            // Arrange - create the controller
            ClipartTemplateController target = new ClipartTemplateController(mock.Object);

            // Act - call the Image method
            HttpResponseMessage result = target.Image(100);

            // Assert
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.StatusCode, HttpStatusCode.BadRequest);
        }
Exemplo n.º 6
0
        public void Can_Retrieve_Clipart_Image_Data()
        {
            // Arrange - create a ClipartTemplate with image data
            ClipartTemplate clipartTemplate = new ClipartTemplate
            {
                Id = 1,
                Name = "ClipartTemplate1",
                Image = new byte[] { }
            };

            // Arrange - create the mock repository
            Mock<IRepository<ClipartTemplate>> mock = new Mock<IRepository<ClipartTemplate>>();
            mock.Setup(m => m.Get(1)).Returns(clipartTemplate);

            // Arrange - create the controller
            ClipartTemplateController target = new ClipartTemplateController(mock.Object);

            // Act - call the Image method
            HttpResponseMessage result = target.Image(1);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.Content.Headers.ContentType.MediaType, "image/png");
        }
Exemplo n.º 7
0
        private void tsbtnClipartTemplateAdd_Click(object sender, EventArgs e)
        {
            TemplateForm frm = new TemplateForm();

            ClipartTemplate template = new ClipartTemplate()
            {
                EffectType = 1,
                Name = "A",
                Text = "A",
                TextColor1 = Color.Red.ToArgb(),
                TextColor2 = Color.Tomato.ToArgb(),
                TextGradientEnable = true,
                OutlineColor1 = Color.Blue.ToArgb(),
                OutlineThickness1 = 1,
                OutlineColor2 = Color.Yellow.ToArgb(),
                OutlineThickness2 = 1,
                ShadowEnable = true,
                ShadowColor = Color.Black.ToArgb(),
                ShadowThickness = 1,
                ShadowOffsetX = 2,
                ShadowOffsetY = 2,
                FontId = fontList[0].Id,
                Font = fontList[0], //ToDo
                ClipartGalleryId = selectedClipartGalleryId
            };

            frm.Template = template;
            frm.Fonts = fontList;

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                template.Font = null;

                _clipartTemplateRepository.Add(template);
                _clipartTemplateRepository.Save();

                imageList.Images.Add(Utils.ByteArrayToImage(template.Image));

                ListViewItem item = new ListViewItem();

                item.ImageIndex = imageList.Images.Count - 1;
                item.Text = template.Name;
                item.Tag = template.Id;

                lvCliparts.Items.Add(item);

                item.Selected = true;
            }

            lvCliparts.Select();

            frm.Dispose();
        }