Пример #1
0
        /// <summary>
        /// 转换为图片信息
        /// </summary>
        private ImageInfo ToImageInfo(HttpPostedFile file, string fileCategory, string baseCategory)
        {
            var path = GetFilePath(file, fileCategory, baseCategory);
            var size = GetSize(file.InputStream);

            return(ImageInfo.Create(path, File.StreamToBytes(file.InputStream), size.Width, size.Height, GetFileName(file)));
        }
 private static ImageInfo CreateImage(string productVersion) =>
 ImageInfo.Create(
     new Image
 {
     Platforms      = Array.Empty <Platform>(),
     ProductVersion = productVersion
 },
     "fullrepo",
     "repo",
     new ManifestFilter(),
     new VariableHelper(new Manifest(), Mock.Of <IManifestOptionsInfo>(), null),
     "base");
Пример #3
0
    private IList <ImageInfo> getImageInfos(MainDocumentPart documentPart)
    {
        List <ImageInfo> r = new List <ImageInfo>();

        foreach (ImagePart image in documentPart.ImageParts)
        {
            ImageInfo imageInfo = ImageInfo.Create(documentPart, image);
            r.Add(imageInfo);
        }

        return(r);
    }
Пример #4
0
 private static ImageInfo CreateImageInfo()
 {
     return(ImageInfo.Create(
                new Image
     {
         Platforms = Array.Empty <Platform>()
     },
                "fullrepo",
                "repo",
                new ManifestFilter(),
                new VariableHelper(new Manifest(), Mock.Of <IManifestOptionsInfo>(), null),
                "base"));
 }
Пример #5
0
        public void TestCreate()
        {
            const string path  = "/a/b.jpg";
            ImageInfo    image = ImageInfo.Create(path, 1, 2, 3, "c.jpg");
            var          icon  = IconFactory.Create(image);

            Assert.AreEqual(path, icon.Path);
            Assert.AreEqual("c.jpg", icon.Name);
            Assert.AreEqual(1, icon.Size);
            Assert.AreEqual(2, icon.Width);
            Assert.AreEqual(3, icon.Height);
            Assert.AreEqual(3, icon.Height);
            Assert.AreEqual("icon-b", icon.ClassName);
        }
Пример #6
0
        public void TestUpload()
        {
            //设置参数
            const string iconUploadPath = "/a/b";
            const string cssPath        = "/a/b/icon.css";
            const string imagePath      = "/a/b/c.jpg";
            var          css            = Icon.CreateCss(imagePath);

            //设置上传文件操作
            _mockUpload.UploadImage(iconUploadPath).Returns(ImageInfo.Create(imagePath, 0, 0, 0));

            //添加图标
            _manager.Upload(Guid.NewGuid(), iconUploadPath, cssPath);

            //验证
            _mockUpload.Received().UploadImage(iconUploadPath);
            _mockIconRepository.Received().Add(Arg.Is <Icon>(icon => icon.Name == "c"));
            _mockFileManager.Received().FilePath = Sys.GetPhysicalPath(cssPath);
            _mockFileManager.Received().Append(Arg.Is(css));
            _mockFileManager.Received().Save();
        }