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 GetConfigBeansTest() { ConfigBeanContainer_Accessor target = new ConfigBeanContainer_Accessor(); // TODO: Initialize to an appropriate value IEnumerable<Arch.CFramework.ConfigBean.Bean.ConfigBean> actual; AppSettingsBean appsettingsBean = new AppSettingsBean(); FCConfigBean fcconfigBean = new FCConfigBean(); target.Register(appsettingsBean); target.Register(fcconfigBean); actual = target.GetConfigBeans(); Assert.IsNotNull(actual); }
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 Arch.CFramework.ConfigBean.Bean.ConfigBean expected = null; // TODO: Initialize to an appropriate value Arch.CFramework.ConfigBean.Bean.ConfigBean actual; AppSettingsBean appsettingsBean = new AppSettingsBean(); FCConfigBean fcconfigBean = new FCConfigBean(); target.Register(appsettingsBean); target.Register(fcconfigBean); //属性值为空,返回NULL actual = target.GetConfigBean(typeName); Assert.AreEqual(expected, actual); //不存在键,返回NULL typeName = "testbean"; actual = target.GetConfigBean(typeName); Assert.AreEqual(expected, actual); //存在 typeName = "appsettingsbean"; expected = appsettingsBean; actual = target.GetConfigBean(typeName); Assert.AreNotEqual(expected, actual); }
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); }