Unit testing the Viewmodel

前端 未结 6 2083
既然无缘
既然无缘 2021-02-05 18:03

I am sort of new to TDD. I have started creating the properties I need on the view model as plain auto property.

public string Firstname { get; set; }

6条回答
  •  感情败类
    2021-02-05 18:42

    A test should fail unless the behavior it is testing is already implemented.

    For testing property change notifications in my last attempt, I created a helper class that helped me write tests like this (It's in NUnit)

    [Test]
    public void NotifiesChangeIn_TogglePauseTooltip()
    {
       var listener = new PropertyChangeListener(_mainViewModel);
    
       _mainViewModel.TogglePauseCommand.Execute(null);
    
       Assert.That(listener.HasReceivedChangeNotificationFor("TogglePauseTooltip"));
    }
    

提交回复
热议问题