public void BasicTest() { int cStylesOrig = m_styleSheet.CStyles; Assert.IsTrue(cStylesOrig > 10); Assert.IsNotNull(m_styleSheet.GetStyleRgch(0, "Section Head")); Assert.IsNotNull(m_styleSheet.GetStyleRgch(0, "Verse Number")); // create four new proxies; verify that they properly determine if they are // mapped to the TE default stylesheet int wsVern = Cache.DefaultVernWs; int wsAnal = Cache.DefaultAnalWs; ImportStyleProxy proxy1 = new ImportStyleProxy("Section Head", StyleType.kstParagraph, wsVern, ContextValues.Text, m_styleSheet); Assert.IsFalse(proxy1.IsUnknownMapping, "Section Head style should exist in DB"); ImportStyleProxy proxy2 = new ImportStyleProxy("Verse Number", StyleType.kstCharacter, wsVern, ContextValues.Text, m_styleSheet); Assert.IsFalse(proxy2.IsUnknownMapping, "Verse Number style should exist in DB"); string proxy3Name = "Tom Bogle"; ImportStyleProxy proxy3 = new ImportStyleProxy(proxy3Name, StyleType.kstParagraph, wsVern, m_styleSheet); //defaults to Text context Assert.IsTrue(proxy3.IsUnknownMapping, "Tom Bogle style shouldn't exist in DB"); string proxy4Name = "Todd Jones"; ImportStyleProxy proxy4 = new ImportStyleProxy(proxy4Name, StyleType.kstCharacter, wsVern, m_styleSheet); //defaults to Text context Assert.IsTrue(proxy4.IsUnknownMapping, "Todd Jones style shouldn't exist in DB"); // verify basic proxy info - name, context, structure, function, styletype, endmarker Assert.AreEqual("Section Head", proxy1.StyleId); Assert.AreEqual(ContextValues.Text, proxy1.Context); Assert.AreEqual(StructureValues.Heading, proxy1.Structure); Assert.AreEqual(StyleType.kstParagraph, proxy1.StyleType); Assert.IsNull(proxy1.EndMarker); Assert.AreEqual(ContextValues.Text, proxy2.Context); Assert.AreEqual(StructureValues.Body, proxy2.Structure); Assert.AreEqual(FunctionValues.Verse, proxy2.Function); Assert.AreEqual(StyleType.kstCharacter, proxy2.StyleType); Assert.IsNull(proxy2.EndMarker); Assert.AreEqual(ContextValues.Text, proxy3.Context); // getting the text props will cause the style to be created in the database ITsTextProps props = proxy3.TsTextProps; IStStyle dbStyle = m_styleSheet.FindStyle(proxy3Name); Assert.AreEqual(ScrStyleNames.NormalParagraph, dbStyle.BasedOnRA.Name); Assert.AreEqual(StyleType.kstParagraph, proxy3.StyleType); Assert.IsNull(proxy3.EndMarker); Assert.AreEqual(ContextValues.Text, proxy4.Context); props = proxy4.TsTextProps; dbStyle = m_styleSheet.FindStyle(proxy4Name); Assert.IsNull(dbStyle.BasedOnRA); Assert.AreEqual(StyleType.kstCharacter, proxy4.StyleType); Assert.IsNull(proxy4.EndMarker); // use SetFormat to add formatting props to unmapped proxy3 ITsPropsBldr tsPropertiesBldr = TsStringUtils.MakePropsBldr(); tsPropertiesBldr.SetIntPropValues((int)FwTextPropType.ktptItalic, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); ITsTextProps formatProps3 = tsPropertiesBldr.GetTextProps(); proxy3.SetFormat(formatProps3, false); // Test retrieval of ParaProps and TsTextProps Assert.IsNotNull(proxy1.TsTextProps); Assert.IsNotNull(proxy2.TsTextProps); // Besides returning the props, retrieving ParaProps or TsTextProps adds a // previously unmapped style to the stylesheet, so that proxy becomes mapped // Next two calls force creation of new styles Assert.IsNotNull(proxy3.TsTextProps); // has benefit of SetFormat Assert.IsFalse(proxy3.IsUnknownMapping, "Tom Bogle style should be created when getting TsTextProps"); Assert.IsFalse(proxy4.IsUnknownMapping, "Todd Jones style should be created when getting ParaProps"); // verify that two new styles were added to the style sheet Assert.AreEqual(cStylesOrig + 2, m_styleSheet.CStyles); // verify that the added styles have the appropriate context, etc IStStyle style = m_styleSheet.FindStyle("Tom Bogle"); Assert.AreEqual(ContextValues.Text, (ContextValues)style.Context); Assert.AreEqual(StructureValues.Body, (StructureValues)style.Structure); Assert.AreEqual(FunctionValues.Prose, (FunctionValues)style.Function); // Test the styletype override from stylesheet // We will attempt to construct a paragraph style proxy, // but since in the stylesheet Chapter Number is a character style, // character will override ImportStyleProxy proxy = new ImportStyleProxy("Chapter Number", StyleType.kstParagraph, wsVern, m_styleSheet); //override as char style Assert.AreEqual(StyleType.kstCharacter, proxy.StyleType, "Should override as character style"); // verify TagType, EndMarker info proxy = new ImportStyleProxy("Xnote", // This style doesn't exist in DB StyleType.kstParagraph, wsVern, ContextValues.Note, m_styleSheet); proxy.EndMarker = "Xnote*"; Assert.AreEqual(ContextValues.Note, proxy.Context); Assert.AreEqual("Xnote*", proxy.EndMarker); // Verify that proxy doesn't attempt to create style when context is EndMarker proxy = new ImportStyleProxy("Xnote*", 0, 0, ContextValues.EndMarker, m_styleSheet); int cStylesX = m_styleSheet.CStyles; // These calls should not add new style Assert.IsNull(proxy.TsTextProps); //no props returned Assert.AreEqual(ContextValues.EndMarker, proxy.Context); Assert.IsTrue(proxy.IsUnknownMapping, "Xnote* should not exist"); Assert.AreEqual(cStylesX, m_styleSheet.CStyles); }