Exemplo n.º 1
0
        public DicomAdapterContext GetDatabaseContext()
        {
            var options = new DbContextOptionsBuilder <DicomAdapterContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            var databaseContext = new DicomAdapterContext(options);

            databaseContext.Database.EnsureDeleted();
            databaseContext.Database.EnsureCreated();
            if (databaseContext.SourceApplicationEntities.Count() <= 0)
            {
                for (int i = 1; i <= 10; i++)
                {
                    databaseContext.SourceApplicationEntities.Add(
                        new SourceApplicationEntity
                    {
                        AeTitle = $"AET{i}",
                        HostIp  = $"{i}.{i}.{i}.{i}"
                    });
                }
            }
            databaseContext.SaveChanges();
            return(databaseContext);
        }
Exemplo n.º 2
0
        public DicomAdapterRepository(IServiceScopeFactory serviceScopeFactory)
        {
            if (serviceScopeFactory is null)
            {
                throw new ArgumentNullException(nameof(serviceScopeFactory));
            }

            _scope = serviceScopeFactory.CreateScope();
            _dicomAdapterContext = _scope.ServiceProvider.GetRequiredService <DicomAdapterContext>();
        }
Exemplo n.º 3
0
 public DatabaseFixture()
 {
     DbContext = GetDatabaseContext();
 }