public AuditTests(ITestOutputHelper output) { _output = output; _dbHelper = new DbHelper <ExampleDbContext>().RunMigrations(); _httpContextAccessor = new TestHttpContextAccessor(); Configuration.AuditDisabled = true; }
public GetUserClaimsQueryHandlerTests(ITestOutputHelper output) { _output = output; _dbHelper = new DbHelper <ExampleDbContext>().RunMigrations(); _handlerDbContext = _dbHelper.GetDbContext(); _httpContextAccessor = new TestHttpContextAccessor(); _handler = new GetUserClaimsQueryHandler <ExampleDbContext>(_handlerDbContext, _httpContextAccessor); }
public CheckUserHasPrivilegeQueryHandlerTests(ITestOutputHelper output) { _output = output; _dbHelper = new DbHelper <ExampleDbContext>().RunMigrations(); _handlerDbContext = _dbHelper.GetDbContext(); _httpContextAccessor = new TestHttpContextAccessor(); _handler = new CheckUserHasPrivilegeQueryHandler <ExampleDbContext>(_handlerDbContext, _httpContextAccessor); }
private IHttpContextAccessor CreateHttpContextAccessor(DateTime deadline = default, CancellationToken cancellationToken = default) { var test = new TestHttpContextAccessor(new DefaultHttpContext()); var serverCallContext = new TestServerCallContext(deadline, cancellationToken); var serverCallContextFeature = new TestServerCallContextFeature(serverCallContext); test.HttpContext.Features.Set <IServerCallContextFeature>(serverCallContextFeature); return(test); }
public InviteNewUserAccountCommandTests() { _dbHelper = new DbHelper <ExampleDbContext>().RunMigrations(); _handlerDbContext = _dbHelper.GetDbContext(); _emailSender = new TestEmailSender(); _httpContextAccessor = new TestHttpContextAccessor(); _testUserService = new TestUserService(); var authEmailSender = new AuthEmailSender(_httpContextAccessor, _emailSender, GetIdentityProviderConfiguration(), GetApplicationConfiguration()); _handler = new InviteNewUserAccountCommandHandler <ExampleDbContext>(_handlerDbContext, authEmailSender, _testUserService); _validator = new InviteNewUserAccountCommandValidator <ExampleDbContext>(_handlerDbContext); }
public void Valid_Configuration_Succeeds() { var configuration = new ListConfiguration(typeof(Request), typeof(Item), typeof(Result)); var configurationProvider = new Mock <IListConfigurationProvider>(); configurationProvider.Setup(x => x.GetConfiguration(It.IsAny <Type>())).Returns(configuration); var requestActivator = new Mock <IModelActivator>(); var requestPropertyActivator = new Mock <IModelPropertyActivator>(); var modelCache = new Mock <IModelCache>(); var httpContext = new Mock <HttpContext>(); var accessor = new TestHttpContextAccessor(httpContext.Object); var services = new ServiceCollection() .AddSingleton(configurationProvider.Object) .AddSingleton(requestActivator.Object) .AddSingleton(requestPropertyActivator.Object) .AddSingleton(modelCache.Object) .AddSingleton <IHttpContextAccessor>(accessor) .BuildServiceProvider(); httpContext.SetupGet(x => x.RequestServices).Returns(services); var context = new TestModelBinderContext(typeof(Request), services); var fallbackModelBinder = new Mock <IModelBinder>(); var fallbackModelBinderProvider = new Mock <IModelBinderProvider>(); fallbackModelBinderProvider.Setup(x => x.GetBinder(It.IsAny <ModelBinderProviderContext>())).Returns(fallbackModelBinder.Object); var provider = new GenericSearchModelBinderProvider(fallbackModelBinderProvider.Object); var modelBinder = provider.GetBinder(context); modelBinder.Should().BeOfType <GenericSearchModelBinder>(); }