Ejemplo n.º 1
0
        public UnitOfWorkFixture()
        {
            var config         = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            var optionsBuilder = new DbContextOptionsBuilder <SampleContext>();

            if (config.GetValue <bool>("UseInMemoryDatabase"))
            {
                optionsBuilder.UseInMemoryDatabase(DateTime.UtcNow.ToString());

                UnitOfWork = new UnitOfWork(new SampleContext(optionsBuilder.Options));

                RoleMock.Generate(UnitOfWork);
                UserMock.Generate(UnitOfWork);
            }
            else
            {
                optionsBuilder.UseSqlServer(config["ConnectionStrings:DefaultConnection"]);

                UnitOfWork = new UnitOfWork(new SampleContext(optionsBuilder.Options));
            }
        }