Ejemplo n.º 1
0
        public virtual void GetInternalImpls()
        {
            "Given all required dlls".Given(() =>
                Log.Info("All required dll's are referenced."));

            "When using the Aspects".When(() =>
            {
                _loggerFactory = Aspects.GetLoggerFactory();
                _di = Aspects.GetIocDI();
                _genericDao = Aspects.GetGenericDao();
                _simpleDao = Aspects.GetSimpleDao();
            });

            "Then all internal implementations are returned".Then(() =>
            {
                _loggerFactory.Should().BeOfType<Log4netLoggerFactory>();
                _di.Should().BeOfType<WindsorDI>();
                _genericDao.Should().BeOfType<NHibernateDao>();
                _simpleDao.Should().BeOfType<NHibernateDao>();

                Log.InfoFormat(
                    "{0}ILoggerFactory  type = {1}" +
                    "{0}IDependencyInj  type = {2}" +
                    "{0}IGenericDao     type = {3}" +
                    "{0}ISimpleDao      type = {4}",
                    Environment.NewLine, _loggerFactory, _di, _genericDao, _simpleDao);
            });
        }
Ejemplo n.º 2
0
        public virtual void GetImpl_Valid_setting(bool dllExists, string setting, Type expected)
        {
            _moqChecker.Setup(s => s.CheckForDll(DllName)).Returns(dllExists);

            string.Format("Given dllAvailable = {0} and setting is [{1}]", dllExists, setting).Given(() =>
                _provider = new SimpleDaoProvider
                {
                    DependencyChecker = _moqChecker.Object,
                    Settings = new NameValueCollection { { KeyName, setting } }
                });

            WhenMsg.When(() =>
                _class = _provider.GetImpl());

            string.Format("Then a {0} should be returned", expected.Name).Then(() =>
                _class.GetType().Should().Be(expected));
        }
Ejemplo n.º 3
0
        public virtual void GetImpl_No_setting_key(bool dllExists, Type expected)
        {
            _moqChecker.Setup(s => s.CheckForDll(DllName)).Returns(dllExists);

            string.Format("Given dll available = {0} and NO '{1}' setting", dllExists, KeyName).Given(() =>
                _provider = new SimpleDaoProvider
                {
                    DependencyChecker = _moqChecker.Object,
                    Settings = new NameValueCollection()// <- don't contain the key
                });

            WhenMsg.When(() =>
                _class = _provider.GetImpl());

            string.Format("Then a {0} should be returned", expected.Name).Then(() =>
                _class.GetType().Should().Be(expected));
        }
Ejemplo n.º 4
0
        public virtual void GetImpl_NoSettings(bool dllExists, Type expected)
        {
            _moqChecker.Setup(s => s.CheckForDll(DllName)).Returns(dllExists);

            string.Format("Given dll available = {0} and NO Settings", dllExists).Given(() =>
                _provider = new SimpleDaoProvider
                {
                    DependencyChecker = _moqChecker.Object,
                    Settings = null//<- no settings
                });

            WhenMsg.When(() =>
                _class = _provider.GetImpl());

            string.Format("Then a {0} should be returned", expected.Name).Then(() =>
               _class.GetType().Should().Be(expected));
        }
Ejemplo n.º 5
0
        public virtual void GetDefaultImpl_ShouldBeNull()
        {
            _moqChecker.Setup(s => s.CheckForDll("Zen.Data.dll")).Returns(false);

            "Given no setting override and Zen.Data.dll is NOT available".Given(() =>
                _provider = new SimpleDaoProvider()
                {
                    Settings = null,
                    DependencyChecker = _moqChecker.Object
                });

            WhenMsg.When(() =>
                _class = _provider.GetImpl());

            "Then null should be returned".Then(() =>
                _class.Should().BeNull());
        }