public void Execute_Test()
        {
            TestExecutionContext.CurrentContext.OutWriter.WriteLine($"{DateTime.Now:hh:mm:ss.fffffff}: Running {TestExecutionContext.CurrentContext.CurrentTest.FullName}");

            IntegrationTest = CreateIntegrationTest();
            EditApiTest();

            var strategy = Context.Database.CreateExecutionStrategy();

            strategy.Execute(() =>
            {
                using var transaction = Context.Database.BeginTransaction();

                IntegrationTest.Setup();
                Context.SaveChanges();
                transaction.Commit();
            });

            IntegrationTest.Run();
            IntegrationTest.Cleanup();

            // Save changes after cleanup
            Context.SaveChanges();

            TestExecutionContext.CurrentContext.OutWriter.WriteLine($"{DateTime.Now:hh:mm:ss.fffffff}: Finished {TestExecutionContext.CurrentContext.CurrentTest.FullName}");
        }
 protected virtual void CleanupActionsAfterTest()
 {
     if (IntegrationTest != null)
     {
         try
         {
             IntegrationTest.Cleanup();
             Context.SaveChanges();
         }
         catch (Exception)
         {
             //Ignore fails because if the setup fails, this might as well fail.
         }
     }
 }
Ejemplo n.º 3
0
 protected override void CleanupActionsAfterTest()
 {
     IntegrationTest.Cleanup();
 }