예제 #1
0
        public void OTFileFieldInitializationHandlingTest()
        {
            bool caughtExpectedException = false; // will set to true if expected exception is caught

            OTFile target = new OTFile();
            Assert.IsNull(target.GetFileInfo(), "Error: unexpected FileInfo");
            Assert.IsNull(target.GetMemoryStream(), "Error: unexpected FileStream");
            try
            {
                OTFont f = target.GetFont(0);
            }
            catch (NullReferenceException)
            {
                caughtExpectedException = true;
            }
            Assert.IsTrue(caughtExpectedException, "Error: expected exception not caught");
            Assert.IsFalse(target.IsCollection, "Error: unexpected value in unopened OTFile");
            Assert.IsFalse(target.IsSupportedFileType, "Error: unexpected value in unopened OTFile");
            Assert.IsTrue(target.Length == 0, "Error: unexpected value in unopened OTFile");
            Assert.IsTrue(target.NumFonts == 0, "Error: unexpected value in unopened OTFile");
            Assert.IsNull(target.SfntVersionTag, "Error: unexpected value in unopened OTFile");
            TtcHeader t = target.TtcHeader;
            Assert.IsTrue(t.FileOffset == 0, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsNull(t.TtcTag, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsTrue(t.MajorVersion == 0, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsTrue(t.MinorVersion == 0, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsTrue(t.NumFonts == 0, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsNull(t.OffsetTableOffsets, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsNull(t.DSIGTag, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsTrue(t.DSIGLength == 0, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsTrue(t.DSIGOffset == 0, "Error: unexpected value in unconfigured TtcHeader");
            Assert.IsFalse(t.HasDSIG, "Error: unexpected value in unconfigured TtcHeader");
        }
예제 #2
0
        public void OTFileGetFileInfoTest()
        {
            OTFile target = new OTFile();

            string FilePath = "TestData\\selawk.ttf";
            try
            {
                target.ReadFromFile(FilePath);
            }
            catch (Exception)
            {
                // unexpected exception
            }

            FileInfo expected = new FileInfo(FilePath);
            FileInfo actual = target.GetFileInfo();
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.IsTrue(actual.Length == expected.Length);
            Assert.IsTrue(actual.Name == "selawk.ttf");
            Assert.IsTrue(actual.Extension == ".ttf");
            Assert.IsTrue(actual.DirectoryName == Directory.GetCurrentDirectory() + "\\TestData");
        }