Last active
October 14, 2018 10:25
-
-
Save worldbeater/667a90f9ca8a1c7f8a2b8ae98c765731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void ShouldValidateFormAndSendFeedback() | |
{ | |
// Create stubs for all dependencies and inject them. | |
var sender = Substitute.For<ISender>(); | |
var clock = Substitute.For<IClock>(); | |
var feedback = new FeedbackViewModel(sender, clock); | |
feedback.HasErrors.Should().BeTrue(); | |
// Emulate user input. | |
feedback.Message = "Message!"; | |
feedback.Title = "Title!"; | |
feedback.Section = 0; | |
feedback.Idea = true; | |
// Ensure there is no errors after we | |
// filled up the form properly. | |
feedback.HasErrors.Should().BeFalse(); | |
// Emulate button click and ensure that the `Send()` | |
// method of the dependency was called only once. | |
feedback.Submit.Execute().Subscribe(); | |
service.Received(1).Send("Title!", "Message!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment