Esempio n. 1
0
        public TestBase()
        {
            var container = new IocContainer();

            this._factory = new ExecutorFactory(container);
            var type     = this.GetType();
            var db       = type.GetAttribute <DbAttribute>();
            var provider = db == null ? "ce" : db.Provider;

            switch (provider)
            {
            case "sql":
                this._testManager = new MsSqlTestManager();
                break;

            default:
                this._testManager = new MsCeTestManager();
                break;
            }
            this._Engine = this._testManager.Engine;

            container.Add <IDbEngine>(lmps => this.Context);

            var classScripts = this.GetType().GetAttribute <ScriptsAttribute>();

            if (classScripts != null)
            {
                this._testManager.Execute(classScripts.Keys);
            }
        }
Esempio n. 2
0
 public void Dispose()
 {
     if (this._Engine != null)
     {
         this._Engine.ResetContext();
     }
     this._factory = null;
     this._testManager.Dispose();
 }
Esempio n. 3
0
 void ITestMethodHandler.Finish()
 {
     if (this._Engine != null)
     {
         this._Engine.ResetContext();
     }
     this._factory = null;
     this._testManager.Dispose();
 }
Esempio n. 4
0
        void ITestMethodHandler.Start()
        {
            var container = new IocContainer();

            this._factory = new ExecutorFactory(container);
            var methodInfo = TestContext.MethodInfo.MethodInfo;
            var db         = methodInfo.GetAttribute <DbAttribute>();
            var provider   = db == null ? DbEngineProvider.MicrosoftSqlServerCompact : db.Provider;

            switch (provider)
            {
            case DbEngineProvider.MicrosoftSqlServer:
                this._testManager = new MsSqlTestManager();
                break;

            default:
                this._testManager = new MsCeTestManager();
                break;
            }
            Manager = this._testManager.Manager;
            container.AddService(this.Manager);
            container.AddService <IDbEngine>(lmps => this.Context);

            var methodScripts = methodInfo.GetAttribute <ScriptsAttribute>();

            if (methodScripts != null)
            {
                this._testManager.Execute(methodScripts.Keys);
            }
            else
            {
                var classScripts = this.GetType().GetAttribute <ScriptsAttribute>();
                if (classScripts != null)
                {
                    this._testManager.Execute(classScripts.Keys);
                }
            }
        }