示例#1
0
        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 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();
        }
示例#3
0
        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();
        }
示例#4
0
        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() 相同。
             *
             */
        }
 public void ShouldExecuteSpecifiedNumberOfTimes()
 {
     repeater.Execute();            // Instance of our command repeater
     command.Received(3).Execute(); // Ensure our substitute command was executed thrice!
 }