public void GetConfigBeansTest()
        {
            ConfigBeanContainer_Accessor target = new ConfigBeanContainer_Accessor(); // TODO: Initialize to an appropriate value
            IEnumerable<ConfigBeanBase> actual;

            ConfigBeanBase appsettingsBean = new AppSettingsBean();
            ConfigBeanBase fcconfigBean = new FCConfigBean();
            target.Register(appsettingsBean);
            target.Register(fcconfigBean);

            actual = target.GetConfigBeans();
            //actual不为空
            Assert.IsNotNull(actual);
            //actual个数为2
            int result = 0;
            using (IEnumerator<ConfigBeanBase> enumerator = actual.GetEnumerator())
            {
                while (enumerator.MoveNext())
                    result++;
            }
            Assert.AreEqual(result, 2);
            //actual中含有AppSettingsBean和FCConfigBean
            bool ret = false;
            using (IEnumerator<ConfigBeanBase> enumerator = actual.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.GetType().Name.Equals(appsettingsBean.GetType().Name))
                    {
                        ret = true; break;
                    }
                }
            }
            Assert.IsTrue(ret);
            ret = false;
            using (IEnumerator<IComponent> enumerator = actual.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.GetType().Name.Equals(fcconfigBean.GetType().Name))
                    {
                        ret = true; break;
                    }
                }
            }
            Assert.IsTrue(ret);

            ConfigBeanBase testBean1 = new Arch.CFramework.AppInternals.Test.TestBean1.TestBean();
            ConfigBeanBase testBean2 = new Arch.CFramework.AppInternals.Test.TestBean2.TestBean();
            target.Register(testBean1);
            target.Register(testBean2);
            //actual个数为2
            result = 0;
            using (IEnumerator<ConfigBeanBase> enumerator = actual.GetEnumerator())
            {
                while (enumerator.MoveNext())
                    result++;
            }
            Assert.AreEqual(result, 2);
        }
        public void GetConfigBeanTest()
        {
            string typename = string.Empty; 
            ConfigBeanBase expected = null; 
            ConfigBeanBase actual;
            //typename为空,抛出异常
            bool ret = false;
            try
            {
                actual = ConfigBeanManager.Current.GetConfigBean(typename);
            }
            catch(Exception)
            {
                ret = true;
            }
            Assert.IsTrue(ret);

            //typename不存在,返回Null
            typename = "lala";
            actual = ConfigBeanManager.Current.GetConfigBean(typename);
            Assert.IsNull(actual);

            //typename存在得到ConfigBean
            expected = new AppSettingsBean();
            actual = ConfigBeanManager.Current.GetConfigBean(expected.GetType().Name.ToLowerInvariant());
            Assert.IsNotNull(actual);
            Assert.IsInstanceOfType(actual, expected.GetType());


            expected = new Arch.CFramework.AppInternals.Test.TestBean.AppSettingsBean();
            actual = ConfigBeanManager.Current.GetConfigBean(expected.GetType().FullName.ToLowerInvariant());
            Assert.IsNull(actual);

        }
 public void GetPropertyNamesTest()
 {
     AppSettingsBean target = new AppSettingsBean();
     IEnumerable<PropertyName> actual = target.GetPropertyNames();
     var result = actual.GetEnumerator();
     result.MoveNext();
     Assert.AreEqual( result.Current.Name, ConfigurationManager.AppSettings.AllKeys[ 0 ] );
 }
Example #4
0
 public void SerializerTest()
 {
     TextSerializer target = new TextSerializer(); // TODO: Initialize to an appropriate value
     IComponent component = new AppSettingsBean(); // TODO: Initialize to an appropriate value
     Encoding encode = null; // TODO: Initialize to an appropriate value
     string actual;
     actual = target.Serializer(component, encode);
     Assert.IsNotNull( actual);
     Assert.IsTrue(actual.Length > 0);
 }
Example #5
0
        public void SerializerTest()
        {
            HTMLSerializer target = new HTMLSerializer();
            HttpRequest request = new HttpRequest("~/", "http://localhost/test/appinternals/FeatureContingencies/centrallogging", "action=view");

            HttpResponse response = new HttpResponse(new StringWriter());
            HttpContext.Current = new HttpContext(request, response);
            Arch.CFramework.AppInternals.Configuration.Bean.ConfigBeanBase configBean = null;
            Encoding encode = null;
            string expected = string.Empty;
            string actual;

            //序列化不存在Bean 抛出异常
            bool ret = false;
            try
            {
                actual = target.Serializer(configBean, encode);
            }
            catch (Exception)
            {
                ret = true;
            }
            Assert.IsTrue(ret);

            //序列化实例Bean
            AppSettingsBean appsettingsBean = new AppSettingsBean();
            actual = target.Serializer(appsettingsBean, encode);
            Assert.AreNotEqual(expected, actual);

            actual = target.Serializer(MenusContainer.Current.GetMenus(), encode);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
            actual = target.Serializer(ConfigManager.Current.GetConfigCollection(), encode);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
            actual = target.Serializer(new BuildInfo(), encode);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
            request = new HttpRequest("~/", "http://localhost/test/appinternals/locallog/applog", "action=view");

            FeatureContingency.FeatureContingencyManager.Current.GetFCS();
            HttpContext.Current = new HttpContext(request, response);
            actual = target.Serializer(LocalLogManager.Current.GetLogs(), encode);
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);

            request = new HttpRequest("~/", "http://localhost/test/appinternals/fcs", "");

            FeatureContingency.FeatureContingencyManager.Current.GetFCS();
            HttpContext.Current = new HttpContext(request, response);
            actual = FeatureContingency.FeatureContingencyManager.Current.GetFeatureContingencies(new HTMLSerializer());
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
            var fc = FeatureContingency.FeatureContingencyManager.Current.FeatureContingency("centrallogging");
            actual = fc.Read(new HTMLSerializer());
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Length > 0);
        }
        public void GetConfigBeanTest()
        {
            ConfigBeanContainer_Accessor target = new ConfigBeanContainer_Accessor(); // TODO: Initialize to an appropriate value
            string typeName = string.Empty; // TODO: Initialize to an appropriate value
            ConfigBeanBase expected = null; // TODO: Initialize to an appropriate value
            ConfigBeanBase actual;

            expected = new AppSettingsBean();
            target.Register(expected);

            //属性值为空,抛出异常
            bool ret = false;
            try
            {
                actual = target.GetConfigBean(typeName);
            }
            catch (Exception)
            {
                ret = true;
            }
            Assert.IsTrue(ret);

            //typename不存在,返回NULL
            typeName = "gaga";
            actual = target.GetConfigBean(typeName);
            Assert.IsNull(actual);

            //typename存在
            typeName = expected.GetType().Name.ToLowerInvariant();
            actual = target.GetConfigBean(typeName);
            Assert.AreEqual(actual, expected);
        }