17 April, 2006

Unit testing custom property on a MCMS posting

I needed to unit test a method that retrives a value from a custom property on a Microsoft Content Management Server posting. This is how I did it:

public void GetLanguage_GetLanguageFromPosting()
    using(CmsApplicationContext appCtx = new CmsApplicationContext())

        try {
            Template templ = appCtx.Searches.GetByGuid("{8DD8B72A-31B7-495B-80F9-1319FAA78BF2}") as Template;
            Posting p = appCtx.RootChannel.CreatePosting(templ);
            CustomProperty prop = p.CustomProperties["language"];
            prop.Value = "est";
            Assert.AreEqual("est", NavigationHelper.GetLanguage(p));
        finally {

Tags: ,