コード例 #1
0
        public static void AssertInfo(ITypefaceInfo info, string source, int testIndex)
        {
            Assert.IsNotNull(info);
            Assert.IsTrue(string.IsNullOrEmpty(info.ErrorMessage));

            if (!string.IsNullOrEmpty(source))
            {
                Assert.IsNotNull(info.Source, "Gill Sans info Path was null for test " + testIndex);
                Assert.AreEqual(source, info.Source, "Gill Sans info Path was not equal to " + source + " for test " + testIndex);
            }

            Assert.IsNotNull(info.Fonts, "Gill Sans references was null for " + testIndex);
            Assert.AreEqual(FontTypefaces.Length, info.Fonts.Length, "Gill Sans references was not " + FontTypefaces.Length + " for " + testIndex);
            Assert.AreEqual(DataFormat.TTC, info.SourceFormat, "The source format for the font was not TTC for " + testIndex);

            //First should be normal
            var matches = new List <FontFace>(FontTypefaces);

            foreach (var typeface in info.Fonts)
            {
                Assert.IsNotNull(typeface);
                Assert.AreEqual(FamilyName, typeface.FamilyName, "The font names did not match for the typeface " + typeface);

                bool found = false;

                foreach (var match in matches)
                {
                    if (typeface.FontWeight == match.Weight &&
                        typeface.FontWidth == match.Width &&
                        typeface.Selections == match.Selection)
                    {
                        matches.Remove(match);
                        found = true;
                        break;
                    }
                }

                Assert.IsTrue(found, "The loaded font " + typeface.ToString() + " was not matched against any expected fonts in the collection");
            }

            Assert.AreEqual(0, matches.Count, "Not all the typefaces were matched.");
        }
コード例 #2
0
        public static void AssertInfo(ITypefaceInfo info, string source, int testIndex)
        {
            Assert.IsNotNull(info);
            Assert.IsTrue(string.IsNullOrEmpty(info.ErrorMessage));

            if (!string.IsNullOrEmpty(source))
            {
                Assert.IsNotNull(info.Source, "Roboto info Path was null for test " + testIndex);
                Assert.AreEqual(source, info.Source, "Roboto info Path was not equal to " + source + " for test " + testIndex);
            }

            Assert.IsNotNull(info.Fonts, "Roboto references was null for " + testIndex);
            Assert.AreEqual(1, info.Fonts.Length, "Roboto references was not 1 for " + testIndex);

            var fref = info.Fonts[0];

            Assert.IsNotNull(fref, "Font reference[0] was null for test " + testIndex);
            Assert.AreEqual(FamilyName, fref.FamilyName, "The font names did not match for test " + testIndex);
            Assert.AreEqual(Weight, fref.FontWeight, "The font weights did not match for test " + testIndex);
            Assert.AreEqual(Width, fref.FontWidth, "The font widths did not match for test " + testIndex);
            Assert.AreEqual(Restrictions, fref.Restrictions, "The font restrictions did not match for test " + testIndex);
            Assert.AreEqual(Selections, fref.Selections, "The font selctions did not match for test " + testIndex);
        }