示例#1
1
        /// <summary>
        ///In 的测试
        ///</summary>
        public void In_OutTestHelperString()
        {
            LinkQueue <string> target = new LinkQueue <string>(); // TODO: 初始化为适当的值

            List <string> list = new List <string>()
            {
                "aa", "bb", "cc", "dd", "ee"
            };

            foreach (string item in list)
            {
                target.In(item);
            }

            foreach (string item in list)
            {
                Assert.AreEqual(item, target.Out());
            }

            try
            {
                target.Out();
            }
            catch (Exception myEx)
            {
                Assert.IsInstanceOfType(myEx, typeof(DataStructureException));
            }
        }
示例#2
0
        /// <summary>
        ///GetFront 的测试
        ///</summary>
        public void GetFrontTestHelperInt()
        {
            LinkQueue <int> target = new LinkQueue <int>(); // TODO: 初始化为适当的值

            target.In(100);

            target.In(1);

            Assert.AreEqual(100, target.GetFront());
            Assert.AreEqual(100, target.GetFront());
        }
示例#3
0
        /// <summary>
        ///GetLength 的测试
        ///</summary>
        public void GetLengthTestHelper <T>()
        {
            LinkQueue <T> target = new LinkQueue <T>(); // TODO: 初始化为适当的值

            Assert.AreEqual(0, target.GetLength());

            target.In(default(T));
            Assert.AreEqual(1, target.GetLength());

            target.In(default(T));
            Assert.AreEqual(2, target.GetLength());
        }
示例#4
0
        /// <summary>
        ///Clear 的测试
        ///</summary>
        public void ClearTestHelper <T>()
        {
            LinkQueue <T> target = new LinkQueue <T>(); // TODO: 初始化为适当的值

            target.In(default(T));

            target.In(default(T));

            Assert.IsNotNull(target.Front);
            Assert.IsNotNull(target.Rear);


            target.Clear();
            Assert.IsNull(target.Front);
            Assert.IsNull(target.Rear);
            Assert.AreEqual(0, target.GetLength());
        }
示例#5
0
        //
        //编写测试时,还可使用以下属性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion



        /// <summary>
        ///IsEmpty 的测试
        ///</summary>
        public void IsEmptyTestHelper <T>()
        {
            LinkQueue <T> target   = new LinkQueue <T>(); // TODO: 初始化为适当的值
            bool          expected = true;                // TODO: 初始化为适当的值
            bool          actual;

            actual = target.IsEmpty();
            Assert.AreEqual(expected, actual);

            target.In(default(T));
            Assert.IsFalse(target.IsEmpty());
        }