public async void Handle_Return_true() { // setup _orderAlterationRepositoryMock.Setup(repo => repo.CreateAsync(It.IsAny <OrderAlteration>())) .Returns(Task.FromResult <OrderAlteration>(FakeOrderAlteration())); _orderAlterationRepositoryMock.Setup(repo => repo.SaveChangesAsync()) .Returns(Task.FromResult(1)); // action var handler = new CreateOrderAlterationCommandHandler(_orderAlterationRepositoryMock.Object); var cltToken = new System.Threading.CancellationToken(); CreateOrderAlterationCommand command = new CreateOrderAlterationCommand(5, 0, -2, 1, "testCustomer"); //Act var result = await handler.Handle(command, cltToken); // assert Assert.True(result); }
//[Fact] //public async Task Post_change_status_and_response_ok_status_code() //{ // using (var server = CreateServer()) // { // var content = new StringContent(BuildChangeStatus(), UTF8Encoding.UTF8, "application/json"); // var response = await server.CreateClient() // .PostAsync(Post.ChangeStatus, content); // response.EnsureSuccessStatusCode(); // } //} string BuildOrder() { var order = new CreateOrderAlterationCommand(3, -1, 0, 5, "testCustomer"); return(JsonConvert.SerializeObject(order)); }
public async Task <ActionResult> Add([FromBody] CreateOrderAlterationCommand cmd) { var result = await _mediator.Send(cmd); return(Ok(result)); }