Classes not recognized in their unit test code

คำตอบ Classes not recognized in their unit test code

  • 1 พฤษภาคม 2555 19:19
     
     
    I have a C# class library, which I'll call "MyLibrary," for which I have made a unit test project, which I will call "MyLibrary.Test." MyLibrary contains several class definitions. Currently, all of these references are broken. Specifically, they are marked with the error "The type or namespace name 'MyClass' could not be found (are you missing a using directive or an assembly reference?)." Both the using directive and the assembly reference are present, like so:

    using System;
    using System.Collections.Generic;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using MyLibrary;

    namespace MyLibrary.Test
    {
        /// <summary>
        /// Test class for MyLibrary.MyClass.
        /// </summary>
        [TestClass()]
        public class MyClassTest
        {

            private TestContext testContextInstance;
            public TestContext TestContext [...]

            internal virtual MyClass CreateMyClass()
            {
                [...]
            }

    What is the problem and how do I resolve it?

ตอบทั้งหมด