public void Correctly_constructs_action_executors()
        {
            DatabaseAction[] actions = new DatabaseAction[] { DatabaseAction.Create, DatabaseAction.Update };

            MockRepository mocks = new MockRepository();
            IDatabaseActionResolver resolver = mocks.StrictMock<IDatabaseActionResolver>();
            IDataBaseActionLocator locator = mocks.StrictMock<IDataBaseActionLocator>();

            IDatabaseActionExecutor creator = mocks.StrictMock<IDatabaseActionExecutor>();
            IDatabaseActionExecutor updater = mocks.StrictMock<IDatabaseActionExecutor>();

            using (mocks.Record())
            {
                Expect.Call(resolver.GetActions(RequestedDatabaseAction.Create)).Return(actions);
                Expect.Call(locator.CreateInstance(DatabaseAction.Create)).Return(creator);
                Expect.Call(locator.CreateInstance(DatabaseAction.Update)).Return(updater);
            }

            using (mocks.Playback())
            {
                IDatabaseActionExecutorFactory factory = new DatabaseActionExecutorFactory(resolver, locator);
                IEnumerable<IDatabaseActionExecutor> executors = factory.GetExecutors(RequestedDatabaseAction.Create);
                IList<IDatabaseActionExecutor> executorList = new List<IDatabaseActionExecutor>(executors);

                Assert.That(executorList, Is.EqualTo(new IDatabaseActionExecutor[]{ creator, updater }));
            }

            mocks.VerifyAll();
        }
        public IDatabaseActionExecutor CreateInstance(DatabaseAction databaseAction)
        {
            if (databaseAction != null)
                if(databaseAction.Equals(DatabaseAction.Create))
                {
                    return new DatabaseCreator();
                }
                else if(databaseAction.Equals(DatabaseAction.Update))
                {
                    return new DatabaseUpdater();
                }
                else if (databaseAction.Equals(DatabaseAction.Drop))
                {
                    return new DatabaseDropper();
                }
                else if (databaseAction.Equals(DatabaseAction.TestData))
                {
                    return new DatabaseTestData();
                }
                else if (databaseAction.Equals(DatabaseAction.Baseline))
                {
                    return new DatabaseBaseliner();
                }

            return null;
        }
Beispiel #3
0
        public IDatabaseActionExecutor CreateInstance(DatabaseAction databaseAction)
        {
            if (databaseAction != null)
            {
                if (databaseAction.Equals(DatabaseAction.Create))
                {
                    return(new DatabaseCreator());
                }
                else if (databaseAction.Equals(DatabaseAction.Update))
                {
                    return(new DatabaseUpdater());
                }
                else if (databaseAction.Equals(DatabaseAction.Drop))
                {
                    return(new DatabaseDropper());
                }
                else if (databaseAction.Equals(DatabaseAction.TestData))
                {
                    return(new DatabaseTestData());
                }
                else if (databaseAction.Equals(DatabaseAction.Baseline))
                {
                    return(new DatabaseBaseliner());
                }
            }

            return(null);
        }