Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > Общие вопросы .NET
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 10.06.2010, 20:50   #1
Pti44ka
Пользователь
 
Аватар для Pti44ka
 
Регистрация: 02.09.2009
Сообщений: 56
По умолчанию Тестирование. В чем же ошибка?

Сгенерировала тест для класса со следующем кодом:
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLibrary
{
    public class Odd
    {
        public static bool IsOdd(int i)
        {
            return i % 2 == 0;
        }
    }
}
Вот мой тест:
Код:
using ClassLibrary;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
 
namespace TestProject1
{
    
    
    /// <summary>
    ///This is a test class for OddTest and is intended
    ///to contain all OddTest Unit Tests
    ///</summary>
    [TestClass()]
    public class OddTest
    {
 
 
        private TestContext testContextInstance;
 
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
 
        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion
 
 
        /// <summary>
        ///A test for Odd Constructor
        ///</summary>
        [TestMethod()]
        public void OddConstructorTest()
        {
            Odd target = new Odd();
            Assert.Inconclusive("TODO: Implement code to verify target");
        }
 
        /// <summary>
        ///A test for IsOdd
        ///</summary>
        [TestMethod()]
        public void IsOddTest()
        {
            int i = 0; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = Odd.IsOdd(i);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
Но в результате у меня получается ошибка:

Assert.AreEqual failed. Expected:<False>. Actual:<True>.
В чем же ошибка?

Последний раз редактировалось Pti44ka; 10.06.2010 в 20:54.
Pti44ka вне форума Ответить с цитированием
Старый 11.06.2010, 00:34   #2
akasex
Форумчанин Подтвердите свой е-майл
 
Аватар для akasex
 
Регистрация: 31.03.2008
Сообщений: 179
По умолчанию

"The Assert class throws an AssertFailedException to signal a failure. This exception should not be captured. This exception is handled by the unit test engine to indicate an assert failure."
akasex вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
В чем ошибка? jahongir007 Помощь студентам 4 12.06.2009 10:25
В чем ошибка? Smartbass Паскаль, Turbo Pascal, PascalABC.NET 1 28.05.2009 21:55
В ЧЕМ ОШИБКА? salmanbaz Общие вопросы C/C++ 5 11.01.2009 13:21
В чем ошибка!!! juden Общие вопросы Delphi 12 10.03.2008 08:53