public void Test_Construct_WithSpecifiedView_ThatDoesNotExist_ShouldReturnDefaultView() { //---------------Set up test pack------------------- var classDef = ClassDef.Get <FakeBOWReflectiveProp>(); Habanero.Naked.UIViewCreator viewCreator = CreateUIViewCreator(); var uiDef = viewCreator.GetDefaultUIDef(classDef); const string noneExistantView = "NoneExistantView"; uiDef.UIGrid.Add(new UIGridColumn(null, "ReflectiveProp", null, null, true, 100, PropAlignment.left, null)); classDef.UIDefCol.Add(uiDef); //---------------Assert Precondition---------------- Assert.AreEqual("default", uiDef.Name); Assert.IsTrue(classDef.UIDefCol.Contains("default")); Assert.IsFalse(classDef.UIDefCol.Contains(noneExistantView)); //---------------Execute Test ---------------------- var viewBuilder = new UIDefViewBuilder <FakeBOWReflectiveProp>(noneExistantView); var descriptorCollection = viewBuilder.GetPropertyDescriptors(); //---------------Test Result ----------------------- Assert.AreEqual(2, descriptorCollection.Count); var propertyDescriptor = descriptorCollection[0]; Assert.IsInstanceOf <PropertyDescriptorReflectiveProp>(propertyDescriptor); Assert.AreEqual("ReflectiveProp", propertyDescriptor.Name); }
public void Test_GetGridView_WithReflectiveProp_ShouldReturnPropDescColWithProp() { //---------------Set up test pack------------------- //ClassDef.ClassDefs = new ClassDefCol(); ClassDef.ClassDefs.Remove(typeof(FakeBOWReflectiveProp)); var classDef = typeof(FakeBOWReflectiveProp).MapClass(); ClassDef.ClassDefs.Add(classDef); Habanero.Naked.UIViewCreator viewCreator = CreateUIViewCreator(); var defaultUiDef = viewCreator.GetDefaultUIDef(classDef); defaultUiDef.Name = RandomValueGen.GetRandomString(); defaultUiDef.UIGrid.Add(new UIGridColumn(null, "ReflectiveProp", null, null, true, 100, PropAlignment.left, null)); classDef.UIDefCol.Add(defaultUiDef); var viewBuilder = new UIDefViewBuilder <FakeBOWReflectiveProp>(defaultUiDef.Name); //---------------Assert Precondition---------------- // Assert.IsTrue(ClassDef.ClassDefs.Contains(typeof(FakeBOWReflectiveProp))); Assert.AreEqual(1, defaultUiDef.UIDefCol.Count, "There should be only the reflective column"); //---------------Execute Test ---------------------- PropertyDescriptorCollection descriptorCollection = viewBuilder.GetPropertyDescriptors(); //---------------Test Result ----------------------- Assert.AreEqual(2, descriptorCollection.Count); var propertyDescriptor = descriptorCollection[0]; Assert.IsInstanceOf <PropertyDescriptorReflectiveProp>(propertyDescriptor); Assert.AreEqual("ReflectiveProp", propertyDescriptor.Name); }