예제 #1
0
        public void Execute(TestClass testClass)
        {
            testClass.RunCases(@case =>
            {
                if (@case.Class.IsSubclassOf(typeof(DbTestBase)))
                {
                    ResetDatabases();
                }
                TestDependencyScope.Begin();
                var instance = testClass.Construct();

                @case.Execute(instance);
                instance.Dispose();
                TestDependencyScope.End();

                if (@case.Exception != null && (@case.Exception.GetType() == typeof(DbEntityValidationException)))
                {
                    var ex = @case.Exception as DbEntityValidationException;
                    foreach (var err in ex.EntityValidationErrors)
                    {
                        Console.WriteLine("Error on {0} entity: {1}", err.IsValid ? "valid" : "invalid", err.Entry);
                        foreach (var ve in err.ValidationErrors)
                        {
                            Console.WriteLine("  {0}: {1}", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                }
            });
        }
예제 #2
0
 public void Execute(Case context, Action next)
 {
     TestDependencyScope.Begin();
     next();
     TestDependencyScope.End();
 }