public async Task ClearsMessageTextAfterSending() { await BlobCache.Secure.SaveLogin("Gitter", "TheAccessToken", "Gitter"); var room = new Room { name = "TheRoom", id = "TheRoomId" }; var api = Substitute.For<IGitterApi>(); api.GetMessages(Arg.Any<string>(), Arg.Any<string>()).Returns(Observable.Return((IReadOnlyList<Message>)new List<Message>())); var fixture = new MessagesViewModel(room, api, Substitute.For<IScreen>()); await fixture.LoadMessages.ExecuteAsync(); fixture.MessageText = "TheMessage"; await fixture.SendMessage.ExecuteAsync(); Assert.IsEmpty(fixture.MessageText); }
public async Task SmokeTest() { await BlobCache.Secure.SaveLogin("Gitter", "TheAccessToken", "Gitter"); var room = new Room { name = "TheRoom", id = "TheRoomId" }; var api = Substitute.For<IGitterApi>(); api.GetMessages(Arg.Any<string>(), Arg.Any<string>()).Returns(Observable.Return((IReadOnlyList<Message>)new List<Message>())); var fixture = new MessagesViewModel(room, api, Substitute.For<IScreen>()); await fixture.LoadMessages.ExecuteAsync(); fixture.MessageText = "TheMessage"; await fixture.SendMessage.ExecuteAsync(); api.Received(1).SendMessage(room.id, Arg.Is<SendMessage>(x => x.Text == "TheMessage"), "Bearer TheAccessToken"); }
public async Task CanExecuteWhenMessageIsNotNullOrEmpty() { await BlobCache.Secure.SaveLogin("Gitter", "TheAccessToken", "Gitter"); var room = new Room { name = "TheRoom", id = "TheRoomId" }; var api = Substitute.For<IGitterApi>(); api.GetMessages(Arg.Any<string>(), Arg.Any<string>()).Returns(Observable.Return((IReadOnlyList<Message>)new List<Message>())); var fixture = new MessagesViewModel(room, api, Substitute.For<IScreen>()); await fixture.LoadMessages.ExecuteAsync(); fixture.MessageText = "TheMessage"; Assert.True(fixture.SendMessage.CanExecute(null)); fixture.MessageText = null; Assert.False(fixture.SendMessage.CanExecute(null)); fixture.MessageText = String.Empty; Assert.False(fixture.SendMessage.CanExecute(null)); fixture.MessageText = " "; Assert.False(fixture.SendMessage.CanExecute(null)); }