Ejemplo n.º 1
0
        public IntegrationTestScope(IntegrationTestBase uat, bool commitChanges = false)
        {
            this.commitChanges = commitChanges;
            this.uat           = uat;

            var Server = new TestServer(new WebHostBuilder().UseStartup <TestServerStartup>());

            uat.IoCContainer = Server.Host.Services.GetService(typeof(IContainer)) as IContainer;
            UnitOfWork unitOfWorkTemp = (uat.UnitOfWork = uat.IoCContainer.GetInstance <IUnitOfWork>()) as UnitOfWork;

            if (!unitOfWorkTemp.AllMigrationsApplied())
            {
                unitOfWorkTemp.Database.Migrate();
                unitOfWorkTemp.EnsureSeeded(uat.IoCContainer);
            }

            if (commitChanges == false)
            {
                uat.StartTransaction();
            }
        }