-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: A Type of Test

Понедельник, 07 Ноября 2016 г. 14:30 + в цитатник

Unit tests are a wonderful tool for proving that your code works. Ideally, when youre using other code, like say, the .NET Framework, you dont write tests that test the framework itself. After all, didnt Microsoft already do that?

David Ts co-worker laughs at your na"ivet'e. Why would you trust Microsoft? You need to make sure the framework works as advertised. Which is why their unit tests are mostly made up of code like this:

    [Test]
    public void It_Converts_DataType_Text_Into_ConcreteType()
    {
        const string dataTypeText = "System.DateTime";

        var dataType = Type.GetType(dataTypeText);

        Assert.IsTrue(dataType == typeof(DateTime));

    }

    [Test]
    public void It_Converts_String_Into_Given_DataType()
    {
        const string data = "10-10-2014";

        const string dataTypeText = "System.DateTime";

        var dataType = Type.GetType(dataTypeText);

        object newData = Convert.ChangeType(data, dataType);

        Assert.That(newData, Is.TypeOf());
    }

Now, if the .NET Frameworks ability to load and recognize types ever breaks, Davids team will be the first to know.

[Advertisement] Application Release Automation – build complex release pipelines all managed from one central dashboard, accessibility for the whole team. Download and learn more today!

http://thedailywtf.com/articles/a-type-of-test

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку