public async Task should_add_note_to_customer() { // Arrange var customerId = Guid.NewGuid(); Context.AddCustomer(new Customer { Id = customerId, Name = "test", Status = 1, CreationTime = DateTime.Now }); var command = new AddCustomerNoteCommand { Text = "Some text", Id = Guid.NewGuid(), CustomerId = customerId }; var expected = new List <Note> { new Note { Id = command.Id, Text = command.Text } }; // Act var actual = await InvokePost($"api/customer/note", command); // Assert actual.StatusCode.Should().Be(HttpStatusCode.Created); var actualCustomer = Context.GetCustomer(customerId); actualCustomer.Notes.Should().BeEquivalentTo(expected); }
public IActionResult AddNote([FromBody] AddCustomerNoteCommand command) { // TODO handle duplicates _addCustomerNoteCommandHandler.Handle(command); return(StatusCode((int)HttpStatusCode.Created)); }