TestBase.cs 969 B

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