public GetFeatureFlagByResourceIdRequestHandlerTests() { var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; _context = new SemaphoreContext(dbOptions); var feature = new Feature { ResourceId = _resourceId, Name = Name }; for (var i = 0; i < SignalsCount; i++) { feature.Signals.Add(new Signal { Value = (i % 2 == 0).ToString(), Tags = i.ToString() }); } _context.Features.Add(feature); _context.SaveChanges(); _sut = new GetFeatureFlagByResourceIdRequestHandler(_context); }
public PatchSignalRequestHandlerTests() { var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; _context = new SemaphoreContext(dbOptions); _sut = new PatchSignalRequestHandler(_context, _mediatorMock.Object); }
public CreateFeatureFlagRequestHandlerTests() { var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; _context = new SemaphoreContext(dbOptions); _sut = new CreateFeatureFlagRequestHandler(_context); }
public GetSettingRequestHandlerTests() { var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; _context = new SemaphoreContext(dbOptions); _context.Add(new Setting { Name = Name, Value = Value }); _context.SaveChanges(); _sut = new GetSettingRequestHandler(_context); }
public GetSignalByNameRequestHandlerTests() { var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; _context = new SemaphoreContext(dbOptions); _context.Signals.Add(new Signal { Id = 1, ResourceId = _resourceId, Name = Name, Value = Value, ValueType = Value.GetSignalValueType(), IsBaseType = Value.IsBaseType(), DateCreated = DateTime.Now, DateLastUpdated = DateTime.Now }); _context.SaveChanges(); _sut = new GetSignalByNameRequestHandler(_context, _mediatorMock.Object); }
private static void Migrate(string connectionString) { var currentAssemblyName = typeof(ServiceCollectionExtensions).Assembly.GetName().Name; try { var migrationOptions = new DbContextOptionsBuilder <SemaphoreContext>().UseNpgsql( connectionString, db => { db.MigrationsAssembly(currentAssemblyName); }) .Options; var migrationContext = new SemaphoreContext(migrationOptions); var pendingMigrations = migrationContext.Database.GetPendingMigrations(); if (pendingMigrations != null && pendingMigrations.Any()) { migrationContext.Database.Migrate(); } } catch (Exception ex) { throw new Exception("An error occurred migrating the database.", ex); } }
public GetFeatureFlagByNameAndTagRequestHandlerTests() { var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; _context = new SemaphoreContext(dbOptions); _context.Features.Add(new Feature { ResourceId = _resourceId, Name = Name, Signals = new List <Signal> { new Signal { Tags = $"Tag1,Tag2,Tag3,{Tag}", Value = Value.ToString() } } }); _context.SaveChanges(); _sut = new GetFeatureFlagByNameAndTagRequestHandler(_context); }
public GetSignalByNameAndTagRequestHandler(SemaphoreContext context, IMediator mediator) { _context = context; _mediator = mediator; }
public GetSettingRequestHandler(SemaphoreContext context) { _context = context; }
public CreateSignalRequestHandler(SemaphoreContext context, IMediator mediator) { _context = context; _mediator = mediator; }
public PatchSignalRequestHandler(SemaphoreContext semaphoreContext, IMediator mediator) { _semaphoreContext = semaphoreContext; _mediator = mediator; }
public GenerateKeysRequestHandler(SemaphoreContext context) { _context = context; }
public CreateFeatureFlagRequestHandler(SemaphoreContext context) { _context = context; }
public GetFeatureFlagByResourceIdRequestHandler(SemaphoreContext context) { _context = context; }
public GetFeatureFlagByNameAndTagRequestHandler(SemaphoreContext context) { _context = context; }
public RollKeysRequestHandler(SemaphoreContext context, IMediator mediator) { _context = context; _mediator = mediator; }