ApiApprovalTests.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using ApprovalTests;
  5. using ApprovalTests.Reporters;
  6. using PublicApiGenerator;
  7. using System.Reflection;
  8. using Xunit;
  9. namespace ReactiveTests.Tests.Api
  10. {
  11. [UseReporter(typeof(DiffReporter))]
  12. public class ApiApprovalTests
  13. {
  14. [Fact]
  15. public void Core()
  16. {
  17. var publicApi = GeneratePublicApi(typeof(System.Reactive.Unit).Assembly);
  18. Approvals.Verify(publicApi);
  19. }
  20. [Fact]
  21. public void Aliases()
  22. {
  23. var publicApi = GeneratePublicApi(typeof(System.Reactive.Observable.Aliases.QueryLanguage).Assembly);
  24. Approvals.Verify(publicApi);
  25. }
  26. [Fact]
  27. public void Testing()
  28. {
  29. var publicApi = GeneratePublicApi(typeof(Microsoft.Reactive.Testing.TestScheduler).Assembly);
  30. Approvals.Verify(publicApi);
  31. }
  32. string GeneratePublicApi(Assembly assembly)
  33. {
  34. var namespacePrefixWhitelist = new[] { "System", "Microsoft" };
  35. return ApiGenerator.GeneratePublicApi(assembly, whitelistedNamespacePrefixes: namespacePrefixWhitelist);
  36. }
  37. }
  38. }