public async Task GivenTodoWebApiControllers_WhenBeingAnalyzed_ThenEnsureTheyDependOnApplicationFlows() { // Arrange Type applicationFlowInterface = typeof(IApplicationFlow <,>); string[] applicationFlowTypes = Types.InAssembly(typeof(IApplicationFlow <,>).Assembly) .That() .ArePublic() .And().AreInterfaces() .And().ImplementInterface(applicationFlowInterface) .GetTypes() .Where(localType => !string.IsNullOrWhiteSpace(localType.FullName)) .Select(localType => localType.FullName) .ToArray(); // Act TestResult testResult = webApiControllers .Should() .HaveDependencyOnAny(applicationFlowTypes) .GetResult(); await DisplayFailingTypesIfAnyAsync(testResult); // Assert testResult.IsSuccessful.Should().Be(true, "Web API controllers *must* depend on all application flows"); }
public async Task GivenTodoWebApiControllers_WhenBeingAnalyzed_ThenEnsureTheyDoNotDependOnPersistence() { // Arrange PredicateList webApiControllers = GetWebApiControllers(); string[] persistenceNamespaces = Types.InAssembly(typeof(TodoDbContext).Assembly) .GetTypes() .Where(localType => !string.IsNullOrWhiteSpace(localType.Namespace)) .Select(localType => localType.Namespace) .Distinct() .ToArray(); // Act TestResult testResult = webApiControllers.Should().NotHaveDependencyOnAny(persistenceNamespaces).GetResult(); await DisplayFailingTypesIfAnyAsync(testResult); // Assert testResult.IsSuccessful .Should().Be(true, "Web API controllers must *not* depend on persistence related namespaces"); }
public async Task GivenTodoWebApiControllers_WhenBeingAnalyzed_ThenEnsureTheyDoNotDependOnServiceInterfaces() { // Arrange PredicateList webApiControllers = GetWebApiControllers(); string[] serviceInterfaces = Types.InAssembly(typeof(ITodoItemService).Assembly) .That() .ArePublic() .And().AreInterfaces() .GetTypes() .Where(localType => !string.IsNullOrWhiteSpace(localType.FullName)) .Select(localType => localType.FullName) .ToArray(); // Act TestResult testResult = webApiControllers.Should().NotHaveDependencyOnAny(serviceInterfaces).GetResult(); await DisplayFailingTypesIfAnyAsync(testResult); // Assert testResult.IsSuccessful.Should().Be(true, "Web API controllers must *not* depend on any service interface"); }