public async Task WhenAskedItShouldGetTimesheets() { var sender = new ChatEventMessageSender(); var space = new ChatEventSpace(); var message = new ChatEventMessage { Sender = sender }; var chat = new ChatEvent { Space = space, Message = message }; var responder = Substitute.For <IHangoutsChatConnector>(); var timesheet = new Timesheet { Name = "A", UserName = "******", UserEmail = "[email protected]", DepartmentName = "F", Total = 20 }; var info = new TextDeconstructionInformation("Get unsubmited timesheets", null, SentenceTypes.Command); _connector.GetUnsubmittedTimesheetsAsync(DateTime.MinValue).ReturnsForAnyArgs(new[] { timesheet }); // Act var result = await _processor.ProcessCommandAsync(info, chat, responder); // Test System.Threading.Thread.Sleep(150); Assert.AreEqual(null, result.Text); responder .Received() .SendMessageAsync( null, Arg.Is <GoogleChatAddress>(it => it.Sender == sender && it.Space == space), Arg.Any <Card[]>()); }
public async Task WhenAskedItShouldRepeatAsync() { var sender = new ChatEventMessageSender(); var space = new ChatEventSpace(); var message = new ChatEventMessage { Sender = sender }; var chat = new ChatEvent { Space = space, Message = message }; var responder = Substitute.For <IAsyncResponder>(); var info = new TextDeconstructionInformation( "Repeat delay 100 Test", "Time", SentenceTypes.Unknown, new Dictionary <string, string[]> { { "Time", new[] { "100" } } }, null, 1.0); var result = await _processor.ProcessCommandAsync(info, chat, responder, null); responder .DidNotReceive() .SendMessageAsync("Test", Arg.Any <GoogleChatAddress>()); Thread.Sleep(150); responder .Received() .SendMessageAsync("Test", Arg.Is <GoogleChatAddress>(it => it.Space == space && it.Sender == sender)); }
private static ChatEvent CreateEvent(string senderEmail) { var sender = new ChatEventMessageSender() { Email = senderEmail }; var space = new ChatEventSpace(); var message = new ChatEventMessage { Sender = sender }; return(new ChatEvent { Space = space, Message = message }); }
public async Task WhenAskedItShouldRepeatAsync() { var sender = new ChatEventMessageSender(); var space = new ChatEventSpace(); var message = new ChatEventMessage { Sender = sender }; var chat = new ChatEvent { Space = space, Message = message }; var responder = Substitute.For <IAsyncResponder>(); var info = new TextDeconstructionInformation("Repeat delay 1000 Test", null, SentenceTypes.Command); var result = await _processor.ProcessCommandAsync(info, chat, responder); responder.Received().SendMessageAsync("Test", space, null, sender); }