コード例 #1
0
        public void ActivateAndSendCache_WhenCalled_ShouldSendCorrect()
        {
            Mock.Arrange(() => _applicationRecorder.GetCache()).Returns(Enumerable.Empty <string>());
            _sut = new RemoteRecordsSender(_consistentMessageSender, _applicationRecorder, _recorder);

            _sut.ActivateAndSendCache();

            Mock.Assert(() => _consistentMessageSender.SendRemote(string.Empty),
                        Occurs.Exactly(1));
        }
コード例 #2
0
        public async void SendRemote_AfterCallSeveralTimes_ShouldSendMessagesConsistently()
        {
            var taskCompletion = default(TaskCompletionSource <bool>);

            _sut = new СonsistentMessageSender(_textToRemoteSender, _recorder);

            Mock.Arrange(() => _textToRemoteSender.TrySendText(Arg.IsAny <string>())).Returns(CreateCompletion().Task);

            _sut.SendRemote("message1");
            _sut.SendRemote("message2");
            _sut.SendRemote("message3");
            await Task.Delay(200);

            Mock.Assert(() => _textToRemoteSender.TrySendText(Arg.IsAny <string>()), Occurs.Once());
        }
コード例 #3
0
 private void TrySendText(string value)
 {
     _consistentMessageSender.SendRemote(value);
 }