Specificity - assertion library to fall in love with
От: wisdom  
Дата: 25.03.09 07:30
Оценка: 16 (1)
http://specificity.codeplex.com/ — библиотечка
http://wpfonyx.codeplex.com/ — пример использования на практике
Key features:


Попробуем на примерах:
        // вместо Assert.InNotNull
        [TestMethod]
        public void GetView_GivenInstance_ShouldReturnViewInstance()
        {
            DependencyObject element = new DependencyObject();
            View view = View.GetView(element);
            Specify.That(view).ShouldNotBeNull();
        }

        // вместо Assert.AreSame
        [TestMethod]
        public void GetView_GivenInstance_ShouldSetViewElement()
        {
            DependencyObject element = new DependencyObject();
            View view = View.GetView(element);
            Specify.That(view.ViewElement).ShouldBeSameAs(element);
        }

        // вместо try {} catch { Assert.Fail }
        [TestMethod]
        public void GetModel_GivenNull_ShouldThrow()
        {
            Specify.ThatAction(() =>
                {
                    View.GetModel(null);
                }).ShouldThrow<ArgumentNullException>();
        }

        [TestMethod]
        public void SomeProperty_GivenValue_ShouldRaisePropertyChanged()
        {
            DependencyObject element = new DependencyObject();
            View view = View.GetView(element);
            ViewModelCreatedWithView model = new ViewModelCreatedWithView(view);
            PropertyChangedWatcher watcher = new PropertyChangedWatcher(model);
            model.SomeProperty = "xyzzy";
            Specify.That(watcher).ShouldHaveSeen("SomeProperty");
        }

assertion library unit testing
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.