public void HandleModify_ValidAction_UpdatesState(int id, string name) { // Arrange. var hero = new Hero { Id = id, Name = "Tornado" }; var heroes = new List <Hero> { hero }; var keyValuePairs = new Dictionary <string, object> { { "Heroes", heroes } }; _heroesState.Hydrate(keyValuePairs); var payload = new Hero { Id = id, Name = name }; var action = new DetailsState.ModifyAction(payload); // Act. _handleModify.Handle(action, new CancellationToken()); // Assert. Assert.Equal(payload, _heroesState.Heroes.Single()); }
public async Task HandleModify_NotFound_IsHandled() { // Arrange. var action = new DetailsState.ModifyAction(new Hero()); // Act. var exception = await Record.ExceptionAsync(() => _handleModify.Handle(action, new CancellationToken())); // Assert. Assert.Null(exception); }
public void ModifyAction_ValidPayload_SetsPayload(int expectedId, string expectedName) { // Given a well formed action. var payload = new Hero { Id = expectedId, Name = expectedName }; var action = new DetailsState.ModifyAction(payload); // It should be instanciated with the given payload. Assert.Equal(payload, action.Hero); }