public void Test_CheckReceivedCalls_CallReceivedNumberOfSpecifiedTimes_Exception() { var command = Substitute.For <ICommand>(); var repeter = new CommandRepeater(command, 3); repeter.Execute(); command.Received(4).Execute(); }
public void Setup() { // Arrange, arguably cleaner/tidier to do this in the test(s) that uses these, but I like to use my setup, plus it saves repetition which is good command = Substitute.For <ICommand>(); something = new SomethingThatNeedsACommand(command); repeater = new CommandRepeater(command, 3); calculator = Substitute.For <ICalculator>(); dictionary = Substitute.For <IDictionary <string, int> >(); watcher = new CommandWatcher(command); runner = new OnceOffCommandRunner(command); }
public void TearDown() { // break it, break it down command = null; something = null; repeater = null; calculator = null; dictionary = null; watcher = null; runner = null; }
public void Test_CheckReceivedCalls_CallReceivedNumberOfSpecifiedTimes() { // Arrange var command = Substitute.For <ICommand>(); var repeater = new CommandRepeater(command, 3); // Act repeater.Execute(); // Assert // 如果仅接收到2次或者4次,这里会失败。 command.Received(3).Execute(); }
public void ICommand_Execute_CheckReceiveNumberofTimesCall() { //Arrange var command = Substitute.For <ICommand>(); var repeater = new CommandRepeater(command, 3); //Act repeater.Execute(); //Assert //command.Received(2).Execute(); command.Received(3).Execute(); //command.Received(4).Execute(); }
public void Test_CheckReceivedCalls_CallReceivedNumberOfSpecifiedTimes() { //檢查接收到次數 // Arrange var command = Substitute.For <ICommand>(); var repeater = new CommandRepeater(command, 3); // Act repeater.Execute(); // Assert // 如果仅接收到2次或者4次,这里会失败。 command.Received(3).Execute(); // 表示有接收到 >0次 command.Received().Execute(); /* * Received(1) 会检查该调用收到并且仅收到一次。这与默认的 Received() 不同, * 其检查该调用至少接收到了一次。Received(0) 的行为与 DidNotReceive() 相同。 * */ }