vendredi 29 janvier 2016

C# unit testing public properties's namespace cannot be resolved in test calss

I am setting up a unit test project, and am having a weird issue. I can reference my project that the test project is for just fine. I can use objects from the project just fine. The problem is when I am trying to create public properties inside a unit test class, that are objects of the project being tested, the test class then errors saying it cannot resolve the type. I do not understand why that would be. I can better explain through an example below:

The reference below when in the method resolves fine, and builds.

/// <summary>
    /// Testing the default constructor for FundingAccount.cs
    /// </summary>
    public void ConstructorsTest_Default()
    {
        bool success = true;
        try
        {
            PSMIC.Web.Billing.FundingAccount testFundingAccount = new PSMIC.Web.Billing.FundingAccount();

            //was MessageColelction initialized during default constructor
            Assert.IsTrue(testFundingAccount.MessageCollection != null);
        }
        catch(Exception e)
        {
            success = false;
        }

        Assert.IsTrue(success == true);
    }

However, when I try to create a public property in the unit test class, so I can set it in the test class init method to use globally, it cannot resolve the namespace or type?

[TestClass]
public class FundingAccountTest
{
    #region Initialize and Control Flow method(s)

    //this causes error. [The namesppace or type 'PSMIC' could not be found
    public PSMIC.Web.Billing.FundingAccount TestFundingAccount { get; set; }

Any ideas on what I am doing wrong here? Thanks, and happy coding!

Aucun commentaire:

Enregistrer un commentaire