Defining ClassDefinition outside of the library?

Aug 17, 2011 at 5:59 PM
Edited Aug 17, 2011 at 6:18 PM

I'm having two issues that maybe you can help me with. The first one is in your examples ClassDefinition is in the same library as your host, etc... For this library to be reusable these types need to be defined outside of your library, however I can not seem to make that work.

Am I misusing or misunderstanding something?

As an example...

In ClassLibrary2 we have...

 

namespace ClassLibrary2
{
    [Serializable]
    public class Person2
    {
        public string Name { get; set; }
    }
}

 

and as a test...

 

    [TestMethod]
        public void MyTestMethod()
        {
            string template = @"
<#@ import namespace=""ClassLibrary2"" #>
<#@ property name=""Person"" type=""Person2"" processor=""PropertyProcessor"" #>
This is a template displaying one argument: <#= Person.Name #>
";
            CallContext.LogicalSetData("Person", new Person2 { Name = "Wilma" });
            var host = new Host();
            var engine = new Engine();

            var output = engine.ProcessTemplate(template, host);

            Assert.AreNotEqual("ErrorGeneratingOutput", output);
        }

 

Fails. However if I move Person2 into your library (and make the appropriate changes) it will work.

 

My other problem has to do with MSTest. When doing templating inside of a VS2010 test (like the testmethod above) the test adapter throws 

Unit Test Adapter threw exception: Type is not resolved for member....

The test works but after completing the test adapter seems to have a problem getting the dll necessary to cross the appdomain. Do you know of any workaround?

 

Edited because I'm a dummy....

I missed the assembly directive, but I'm still curious about the MSTest problem.

Coordinator
Aug 24, 2011 at 7:43 AM

Hi,

 

I'm glad you found the assembly directive.

 

I'm not sure about your problem with MS Test. I used to run all the tests of the Library without any problem.

If you can send me an example project to reproduce the problem, I will have a look.

 

Best regards,

 

Tim