示例#1
0
        public void TestLoad()
        {
            var resxdata = ResXData.FromFile(resxFile);

            Assert.IsNull(resxdata.ProjectFile);
            CheckEquality(resxdata);
        }
示例#2
0
        public void TestConvertToAndFromResXNode()
        {
            var resxdata = ResXData.FromFile(resxFile);

            foreach (var icon in resxdata.Nodes)
            {
                ResXDataNode node  = icon;
                ResXNode     icon2 = node;

                AreEqual(resxdata.GetValue(icon), resxdata.GetValue(icon2));
                Assert.AreEqual(icon.Name, icon2.Name);
                Assert.AreEqual(icon.TypeName, icon2.TypeName);
                Assert.AreEqual(icon.Comment, icon2.Comment);
            }
        }
示例#3
0
        public void TestGetDrawingImage()
        {
            var resxdata = ResXData.FromFile(resxFile);

            var icon = resxdata.GetDrawingImage(resxdata.Nodes[0]);

            //Assert.AreEqual(System.Drawing.Imaging.ImageFormat.Icon, icon.RawFormat);
            Assert.AreEqual(32, icon.Width);
            Assert.AreEqual(32, icon.Height);

            var bitmap = resxdata.GetDrawingImage(resxdata.Nodes[1]);

            Assert.AreEqual(System.Drawing.Imaging.ImageFormat.Png, bitmap.RawFormat);
            Assert.AreEqual(392, bitmap.Width);
            Assert.AreEqual(243, bitmap.Height);
        }
示例#4
0
        public void TestCreateNode()
        {
            var resxdata = ResXData.FromFile(resxFile);

            var fileRef = (ResXFileRef)resxdata.Nodes[1].ObjectValue;

            Core.FilePath path         = fileRef.FileName;
            var           absolutePath = Path.GetFullPath(path.ToAbsolute(resxdata.Path));
            var           otherNode    = (ResXDataNode)resxdata.CreateNode(absolutePath, typeof(System.Drawing.Bitmap));

            Assert.AreEqual(fileRef.FileName, otherNode.FileRef.FileName);
            Assert.AreEqual(fileRef.TypeName, otherNode.FileRef.TypeName);
            Assert.AreEqual(fileRef.TextFileEncoding, otherNode.FileRef.TextFileEncoding);

            var value      = (System.Drawing.Bitmap)resxdata.GetValue(resxdata.Nodes[0]);
            var otherValue = (System.Drawing.Bitmap)resxdata.GetValue(otherNode);

            Assert.AreEqual(value.Width, otherValue.Width);
            Assert.AreEqual(value.Height, otherValue.Height);
        }
示例#5
0
        public void TestModify()
        {
            string workFile = resxFile.Replace("Image", "Image2");

            try
            {
                File.Copy(resxFile, workFile);
                var resxdata = ResXData.FromFile(workFile);

                resxdata.Nodes.Add(new ResXNode("string", "test", "", "System.String"));

                resxdata.WriteToFile(resxdata.Nodes);

                resxdata = ResXData.FromFile(workFile);
                Assert.AreEqual(3, resxdata.Nodes.Count);
            }
            finally
            {
                File.Delete(workFile);
            }
        }