OrderControllerTest.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using AutoFixture;
  2. using Hotline.Api.Controllers;
  3. using Hotline.Share.Dtos.Order;
  4. using Microsoft.AspNetCore.Http;
  5. using Microsoft.AspNetCore.Mvc;
  6. using Microsoft.AspNetCore.Mvc.Testing;
  7. using Moq;
  8. using Shouldly;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. namespace Hotline.Application.Tests.Controller;
  15. public class OrderControllerTest : IClassFixture<WebApplicationFactory<Startup>>
  16. {
  17. private readonly OrderController _orderController;
  18. private readonly IFixture _fixture;
  19. private readonly WebApplicationFactory<Startup> _factory;
  20. public OrderControllerTest(OrderController orderController, WebApplicationFactory<Startup> factory)
  21. //public OrderControllerTest(HttpClient testClient)
  22. {
  23. _fixture = new Fixture();
  24. _orderController = orderController;
  25. //_testClient = testClient;
  26. _factory = factory;
  27. _orderController.ControllerContext = new ControllerContext
  28. {
  29. HttpContext = new DefaultHttpContext()
  30. };
  31. }
  32. [Fact]
  33. public async Task SendSMS_Test()
  34. {
  35. var inDto = _fixture.Create<VisitSmsInDto>();
  36. await _orderController.VisitPushSMSAsync(inDto);
  37. }
  38. }