0
的RSpec有一個漂亮的期待/結構的變化,即是這樣的:NUnit的等價的RSpec的預期的改變
expect{sut.SomeMethod}.to change{repo.count}.by(1)
https://relishapp.com/rspec/rspec-expectations/v/2-0/docs/matchers/expect-change
是否NUnit的有這樣的事情呢?沿着線的東西:
Expect(() => sut.SomeMethod()).Changes<int>(() => repo.Count()).By(1);
現在,我實現了這個測試是這樣的:
int prevCount = repo.Count();
sut.SomeMethod();
int newCount = repo.Count();
Assert.That(newCount, Is.EqualTo(prevCount + 1);