1
1

TestBase.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. using Masuit.Tools.AspNetCore.ResumeFileResults.WebTest;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.AspNetCore.TestHost;
  4. using System;
  5. using System.IO;
  6. using System.Net.Http;
  7. using System.Net.Http.Headers;
  8. using System.Reflection;
  9. namespace Masuit.Tools.Core.UnitTest.AspNetCore
  10. {
  11. public abstract class TestBase
  12. {
  13. protected TestBase()
  14. {
  15. var path = Path.GetDirectoryName(typeof(Startup).GetTypeInfo().Assembly.Location);
  16. var di = new DirectoryInfo(path).Parent.Parent.Parent;
  17. // Arrange
  18. Server = new TestServer(new WebHostBuilder().UseStartup<Startup>().UseContentRoot(di.FullName));
  19. Client = Server.CreateClient();
  20. }
  21. public HttpClient Client { get; }
  22. public EntityTagHeaderValue EntityTag { get; } = new EntityTagHeaderValue("\"TestFile\"");
  23. public DateTimeOffset LastModified { get; } = new DateTimeOffset(2016, 1, 1, 0, 0, 0, TimeSpan.Zero);
  24. public TestServer Server { get; }
  25. }
  26. }