public static IClassDef LoadClassDef_IncludingCarAndOwner() { new Engine(); new Car(); new ContactPerson(); return(ClassDef.Get <Engine>()); }
public void TestFindAll_UsingClassDef() { //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(new DataStoreInMemory()); ClassDef.ClassDefs.Clear(); ContactPersonTestBO.LoadDefaultClassDef(); OrganisationTestBO.LoadDefaultClassDef(); DataStoreInMemory dataStore = new DataStoreInMemory(); DateTime now = DateTime.Now; ContactPersonTestBO cp1 = new ContactPersonTestBO(); cp1.DateOfBirth = now; cp1.Surname = TestUtil.GetRandomString(); cp1.Save(); dataStore.Add(cp1); ContactPersonTestBO cp2 = new ContactPersonTestBO(); cp2.DateOfBirth = now; cp2.Surname = TestUtil.GetRandomString(); cp2.Save(); dataStore.Add(cp2); Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, now); dataStore.Add(OrganisationTestBO.CreateSavedOrganisation()); //---------------Execute Test ---------------------- IBusinessObjectCollection col = dataStore.FindAll(ClassDef.Get <ContactPersonTestBO>(), criteria); //---------------Test Result ----------------------- Assert.AreEqual(2, col.Count); Assert.Contains(cp1, col); Assert.Contains(cp2, col); }
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_GetValidPropValue_WhenStringAndMaxLengthWhenPropName_ShouldRetValidValue() { //---------------Set up test pack------------------- var classDef = ClassDef.Get <FakeBO>(); var def = classDef.PropDefcol.FirstOrDefault(propDef => propDef.PropertyName == "CompulsoryString"); //---------------Assert Precondition---------------- Assert.IsNotNull(def); def.AddPropRule(CreatePropRuleString(3, 7)); var factory = new BOTestFactory(typeof(FakeBO)); Assert.AreSame(typeof(string), def.PropertyType); Assert.IsNotEmpty(def.PropRules.OfType <PropRuleString>().ToList()); var propRule = def.PropRules.OfType <PropRuleString>().First(); Assert.AreEqual(3, propRule.MinLength); Assert.AreEqual(7, propRule.MaxLength); //---------------Execute Test ---------------------- var validPropValue = factory.GetValidPropValue(typeof(FakeBO), "CompulsoryString").ToString(); //---------------Test Result ----------------------- Assert.IsNotNull(validPropValue); Assert.GreaterOrEqual(validPropValue.Length, 3); Assert.LessOrEqual(validPropValue.Length, 7); string errMessage = ""; Assert.IsTrue(def.IsValueValid(validPropValue, ref errMessage)); }
public void Test_BusinessObject_WhenSet_HavingNonExistingPropertyOnRelatedBO_ShouldThrowError() { //---------------Set up test pack------------------- IClassDef organisationClassDef = ClassDef.Get <OrganisationTestBO>(); ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO(); contactPersonTestBO.Organisation = new OrganisationTestBO(); const string innerPropertyName = "NonExistingProperty"; const string propertyName = "Organisation." + innerPropertyName; BOPropertyMapper boPropertyMapper = new BOPropertyMapper(propertyName); //---------------Assert Precondition---------------- Assert.IsNull(boPropertyMapper.BusinessObject); Assert.IsNull(boPropertyMapper.Property); //---------------Execute Test ---------------------- try { boPropertyMapper.BusinessObject = contactPersonTestBO; Assert.Fail("Expected to throw a HabaneroDeveloperException"); } //---------------Test Result ----------------------- catch (InvalidPropertyException ex) { StringAssert.Contains("The property '" + innerPropertyName + "' on '" + organisationClassDef.ClassName + "' cannot be found. Please contact your system administrator.", ex.Message); /* StringAssert.Contains("The property '" + innerPropertyName + "' does not exist on the BusinessObject '" + organisationClassDef.ClassNameFull + "'", ex.DeveloperMessage);*/ Assert.IsNull(boPropertyMapper.BusinessObject); Assert.IsNull(boPropertyMapper.Property); } }
public void Test_BusinessObject_WhenSet_HavingNonExistingChildRelationshipForRelatedBo_ShouldThrowError() { //---------------Set up test pack------------------- IClassDef contactPersonClassDef = ClassDef.Get <ContactPersonTestBO>(); ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO(); contactPersonTestBO.Organisation = new OrganisationTestBO(); const string innerRelationshipName = "Addresses"; const string outerRelationshipName = "NonExistingRelationship"; const string relationshipName = outerRelationshipName + "." + innerRelationshipName; BORelationshipMapper boRelationshipMapper = new BORelationshipMapper(relationshipName); //---------------Assert Precondition---------------- Assert.IsNull(boRelationshipMapper.BusinessObject); Assert.IsNull(boRelationshipMapper.Relationship); //---------------Execute Test ---------------------- try { boRelationshipMapper.BusinessObject = contactPersonTestBO; Assert.Fail("Expected to throw a HabaneroDeveloperException"); } //---------------Test Result ----------------------- catch (RelationshipNotFoundException ex) { StringAssert.Contains("The relationship '" + outerRelationshipName + "' on '" + contactPersonClassDef.ClassName + "' cannot be found. Please contact your system administrator.", ex.Message); /* StringAssert.Contains("The relationship '" + outerRelationshipName + "' does not exist on the BusinessObject '" + contactPersonClassDef.ClassNameFull + "'", ex.DeveloperMessage);*/ Assert.IsNull(boRelationshipMapper.BusinessObject); Assert.IsNull(boRelationshipMapper.Relationship); } }
[Test] // Checks that deleting this instance has no effect in the related class public void Test_SingleRelationshipDeletion_DoNothing_Car() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- Driver driver = TestUtilsDriver.CreateSavedDriver(); TestProject.BO.Car boForRelationshipCar = TestUtilsCar.CreateSavedCar(); driver.Car = boForRelationshipCar; driver.Save(); //---------------Assert Preconditions--------------- IRelationshipDef relationshipDef = ClassDef.Get <Driver>().RelationshipDefCol["Car"]; Assert.AreEqual(DeleteParentAction.DoNothing, relationshipDef.DeleteParentAction); //---------------Execute Test ---------------------- driver.MarkForDelete(); driver.Save(); //---------------Execute Test ---------------------- BusinessObjectManager.Instance.ClearLoadedObjects(); GC.Collect(); TestUtilsShared.WaitForGC(); try { Broker.GetBusinessObject <Driver>(driver.ID); Assert.Fail("BO should no longer exist and exception should be thrown"); } catch (BusObjDeleteConcurrencyControlException ex) { StringAssert.Contains("There are no records in the database for the Class: Driver", ex.Message); } TestProject.BO.Car relatedBO = Broker.GetBusinessObject <TestProject.BO.Car>(boForRelationshipCar.ID); Assert.AreEqual(relatedBO.ID.ToString(), boForRelationshipCar.ID.ToString()); }
public void Test_CreateMultipleRelationshipDef_Association() { //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(); ClassDef.ClassDefs.Clear(); OrganisationTestBO.LoadDefaultClassDef(); ContactPersonTestBO.LoadDefaultClassDef(); RelPropDef relPropDef = new RelPropDef(ClassDef.Get <OrganisationTestBO>().PropDefcol["OrganisationID"], "OrganisationID"); RelKeyDef relKeyDef = new RelKeyDef(); relKeyDef.Add(relPropDef); const int expectedTimeout = 550; MultipleRelationshipDef relationshipDef = new MultipleRelationshipDef("ContactPeople", "Habanero.Test.BO", "ContactPersonTestBO", relKeyDef, true, "", DeleteParentAction.DeleteRelated, InsertParentAction.InsertRelationship, RelationshipType.Association, expectedTimeout); OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation(); //---------------Assert Precondition---------------- Assert.AreEqual(expectedTimeout, relationshipDef.TimeOut); //---------------Execute Test ---------------------- MultipleRelationship <ContactPersonTestBO> relationship = (MultipleRelationship <ContactPersonTestBO>)relationshipDef.CreateRelationship(organisation, organisation.Props); //---------------Test Result ----------------------- Assert.AreEqual(expectedTimeout, relationship.TimeOut); Assert.AreEqual(InsertParentAction.InsertRelationship, relationship.RelationshipDef.InsertParentAction); }
public void TestLoadNumberGenClassDef_ShouldAddClassDef_BUGFIX_ShouldBeThreadSafe() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- Assert.AreEqual(0, ClassDef.ClassDefs.Count); //---------------Execute Test ---------------------- var exceptions = new List <Exception>(); TestUtil.ExecuteInParallelThreads(2, () => { try { BOSequenceNumber.LoadNumberGenClassDef(); } catch (Exception ex) { exceptions.Add(ex); } }); //---------------Test Result ----------------------- if (exceptions.Count > 0) { Assert.Fail(exceptions[0].ToString()); } Assert.AreEqual(1, ClassDef.ClassDefs.Count); Assert.IsNotNull(ClassDef.Get <BOSequenceNumber>()); }
private Type GetComboBoxMapperType <T>(Control control) where T : class, IBusinessObject { //Note_ the Naming convention is only needed in the registry to deal with // ComboBoxes since they could be enum, Relationship or lookups so have to // get the property name to resolve. string propName = ControlNamingConvention.GetPropName(control); var classDef = ClassDef.Get <T>(); var propDef = classDef.GetPropDef(propName, false); if (propDef == null) { var relationshipDef = classDef.GetRelationship(propName) as ISingleRelationshipDef; if (relationshipDef != null) { return(typeof(AutoLoadingRelationshipComboBoxMapper)); } else { //ToDo: some sort of reflective stuff since this is a reflective prop } return(null); } if (propDef.PropertyType.ToTypeWrapper().IsEnumType()) { return(typeof(EnumComboBoxMapper)); } if (propDef.HasLookupList()) { return(typeof(LookupComboBoxMapper)); } return(null); }
[Test] // Checks that deletion is prevented when a child exists public void Test_MultipleRelationshipDeletion_PreventDelete_Drivers() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- Car car = TestUtilsCar.CreateSavedCar(); TestProject.BO.Driver boForRelationshipDrivers = TestUtilsDriver.CreateUnsavedValidDriver(); boForRelationshipDrivers.CarID = car.VehicleID; boForRelationshipDrivers.Save(); //---------------Assert Preconditions--------------- Assert.AreEqual(1, car.Drivers.Count); IRelationshipDef relationshipDef = ClassDef.Get <Car>().RelationshipDefCol["Drivers"]; Assert.AreEqual(DeleteParentAction.Prevent, relationshipDef.DeleteParentAction); //---------------Execute Test ---------------------- try { car.MarkForDelete(); car.Save(); Assert.Fail("Should have thrown exception due to deletion prevention"); } //---------------Test Result ----------------------- catch (BusObjDeleteException ex) { StringAssert.Contains("You cannot delete Car identified by ", ex.Message); StringAssert.Contains("via the Drivers relationship", ex.Message); } }
public void Test_ShouldHavePropertyMapped_WhenPropSetterMappedToInvalidName_ShouldAssertFalse() { BORegistry.DataAccessor = new DataAccessorInMemory(); //---------------Set up test pack------------------- const string relName = "SingleRelSetterMappedToNonExistentRelDef"; CreateClassDefs <FakeBOWithNothing, FakeBoWithSingleRel>(); var classDef = ClassDef.Get <FakeBoWithSingleRel>(); var boTester = CreateTester <FakeBoWithSingleRel>(); var singleRelDefTester = boTester.GetSingleRelationshipTester(rel => rel.SingleRelSetterMappedToNonExistentRelDef); //---------------Assert Precondition---------------- classDef.ShouldHaveSingleRelationshipDef(relName); classDef.ShouldHavePropertyInfo(relName); //---------------Execute Test ---------------------- try { singleRelDefTester.ShouldHavePropertyMapped(); Assert.Fail("Expected to throw an AssertionException "); } //---------------Test Result ----------------------- catch (AssertionException ex) { string expected = string.Format("The Setter for the Property '{0}' for class '{1}'", relName, "FakeBoWithSingleRel"); StringAssert.Contains(expected, ex.Message); StringAssert.Contains("Setting the Property via reflection failed", ex.Message); } }
public void Test_ShouldHavePropertyMapped_WhenPropWithNoSetter_GetterNotCorrectlyMapped_ShouldAssertFalse() { BORegistry.DataAccessor = new DataAccessorInMemory(); //---------------Set up test pack------------------- const string relName = "SingleRelNoSetterGetterIncorrect"; CreateClassDefs <FakeBOWithNothing, FakeBoWithSingleRel>(); var classDef = ClassDef.Get <FakeBoWithSingleRel>(); var boTester = CreateTester <FakeBoWithSingleRel>(); var singleRelDefTester = boTester.GetSingleRelationshipTester(rel => rel.SingleRelNoSetterGetterIncorrect); //---------------Assert Precondition---------------- classDef.ShouldHaveSingleRelationshipDef(relName); classDef.ShouldHavePropertyInfo(relName); //---------------Execute Test ---------------------- try { singleRelDefTester.ShouldHavePropertyMapped(); Assert.Fail("Expected to throw an AssertionException"); } //---------------Test Result ----------------------- catch (AssertionException ex) { string expected = string.Format("The Getter for the Property '{0}' for class '{1}'", relName, "FakeBoWithSingleRel"); StringAssert.Contains(expected, ex.Message); StringAssert.Contains("is not mapped to the correct BOProp. Check the Property in your code", ex.Message); } }
public void TestGridRowChange_DoesNotChangeWhenBOInvalid() { //---------------Set up test pack------------------- IClassDef classDef = ClassDef.Get <MyBO>(); classDef.PropDefcol["TestProp"].Compulsory = true; BusinessObjectCollection <MyBO> myBOs = CreateSavedMyBoCollection(); IGridWithPanelControl <MyBO> gridWithPanelControl = CreateGridAndBOEditorControl_WithStrategy(); gridWithPanelControl.SetBusinessObjectCollection(myBOs); MyBO firstBO = myBOs[0]; MyBO secondBO = myBOs[1]; firstBO.TestProp = ""; //---------------Assert Precondition---------------- Assert.IsFalse(firstBO.Status.IsNew); Assert.IsFalse(firstBO.Status.IsValid()); Assert.AreEqual(0, gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedRows[0].Index); Assert.AreSame(firstBO, gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedBusinessObject); //---------------Execute Test ---------------------- gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedBusinessObject = secondBO; //gridWithPanelControl.ReadOnlyGridControl.Grid.CurrentCell = // gridWithPanelControl.ReadOnlyGridControl.Grid.Rows[1].Cells[1]; //---------------Test Result ----------------------- Assert.AreEqual(0, gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedRows[0].Index); Assert.AreSame(firstBO, gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedBusinessObject); Assert.IsTrue(firstBO.Status.IsDirty); }
private static IClassDef GetClassDef() { if (ClassDef.IsDefined(typeof(BOWithCompositePK))) { return(ClassDef.Get <BOWithCompositePK>()); } return(CreateClassDef()); }
void Awake() { if (Game.PlayerCharacter == null) { Game.PlayerCharacter = new Character(CharacterDef.Get("Widow Tarha"), ClassDef.Get("Necromancer")); //Game.PlayerCharacter.AddItem(ItemDef.Get("Steel Broadsword")); //Game.PlayerCharacter.AddItem(ItemDef.Get("Light Hammer")); } }
///<summary> /// Constructor for <see cref="BusinessObjectPanelVWG{T}"/> ///</summary> ///<param name="controlFactory"></param> ///<param name="uiDefName"></param> public BusinessObjectPanelVWG(IControlFactory controlFactory, string uiDefName) { PanelBuilder panelBuilder = new PanelBuilder(controlFactory); _panelInfo = panelBuilder.BuildPanelForForm(ClassDef.Get <T>().UIDefCol[uiDefName].UIForm); BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this); layoutManager.AddControl(_panelInfo.Panel, BorderLayoutManager.Position.Centre); this.Size = _panelInfo.Panel.Size; this.MinimumSize = _panelInfo.Panel.Size; }
/// <summary> /// Constructs a <see cref="PropertyDescriptorCollection"/> based on the <see cref="UIDef"/> /// defined for this class. Will also create a <see cref="UIDef"/> based on <see cref="Habanero.Naked"/>. /// </summary> /// <returns></returns> public virtual PropertyDescriptorCollection GetPropertyDescriptors() { var classDef = ClassDef.Get <T>(); var uiDef = classDef.UIDefCol.Contains(_uiName) ? classDef.UIDefCol[_uiName] : new UIViewCreator(new DefClassFactory()).GetDefaultUIDef(classDef); var uiGrid = uiDef.UIGrid; var propertyDescriptors = uiGrid.Select(GetPropertyDescriptor).ToList(); propertyDescriptors.Add(new PropertyDescriptorID()); return(new PropertyDescriptorCollection(propertyDescriptors.ToArray())); }
private Type GetNumericUpDownMapperType <TBo>(Control control) where TBo : class, IBusinessObject { string propName = ControlNamingConvention.GetPropName(control); var classDef = ClassDef.Get <TBo>(); var propDef = classDef.GetPropDef(propName, false); if (propDef == null) { return(null); } return(IsInteger(propDef) ? typeof(NumericUpDownIntegerMapper) : typeof(NumericUpDownCurrencyMapper)); }
public void TestLoadNumberGenClassDef_ShouldAddClassDef() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- Assert.AreEqual(0, ClassDef.ClassDefs.Count); //---------------Execute Test ---------------------- BOSequenceNumber.LoadNumberGenClassDef(); //---------------Test Result ----------------------- Assert.AreEqual(1, ClassDef.ClassDefs.Count); Assert.IsNotNull(ClassDef.Get <BOSequenceNumber>()); }
private void CreateBoSelectorAndEditorManager(out IBOColSelectorControl boColSelector, out IBusinessObjectControl boEditor) { IClassDef classDef = ClassDef.Get <MyBO>(); boColSelector = GetControlFactory().CreateReadOnlyGridControl(); boEditor = GetControlFactory().CreateBOEditorControl(classDef); new BOSelectorAndEditorManager(boColSelector, boEditor); IFormHabanero form = GetControlFactory().CreateForm(); form.Controls.Add(boColSelector); return; }
/// <summary> /// Returns the business object of the type provided that meets the search criteria. /// An exception is thrown if more than one business object is found that matches the criteria. /// If that situation could arise, rather use GetBusinessObjectCol. /// </summary> /// <param name="selectQuery">The select query</param> /// <returns>Returns the business object found</returns> /// <exception cref="UserException">Thrown if more than one object matches the criteria</exception> public T GetBusinessObject <T>(ISelectQuery selectQuery) where T : class, IBusinessObject, new() { var classDef = ClassDef.Get <T>(); var source = selectQuery.Source; QueryBuilder.PrepareSource(classDef, ref source); selectQuery.Source = source; QueryBuilder.PrepareCriteria(classDef, selectQuery.Criteria); var selectQueryDB = new SelectQueryDB(selectQuery, _databaseConnection); var statement = selectQueryDB.CreateSqlStatement(); IClassDef correctSubClassDef = null; T loadedBo = null; var objectUpdatedInLoading = false; using (var dr = _databaseConnection.LoadDataReader(statement)) { if (dr.Read()) { loadedBo = LoadBOFromReader <T>(dr, selectQueryDB, out objectUpdatedInLoading); //Checks to see if the loaded object is the base of a single table inheritance structure // and has a sub type if so then returns the correct sub type. correctSubClassDef = GetCorrectSubClassDef(loadedBo, dr); //Checks to see if there is a duplicate object meeting this criteria if (dr.Read()) { ThrowRetrieveDuplicateObjectException(statement, loadedBo); } } } if (correctSubClassDef != null) { loadedBo = GetLoadedBoOfSpecifiedType(loadedBo, correctSubClassDef); } if (loadedBo == null) { return(null); } var isFreshlyLoaded = loadedBo.Status.IsNew; SetStatusAfterLoad(loadedBo); if (objectUpdatedInLoading) { CallAfterLoad(loadedBo); if (!isFreshlyLoaded) { FireUpdatedEvent(loadedBo); } } return(loadedBo); }
public void Test_Inheritance_SuperClassDef_Exists() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ISuperClassDef superClassDef = ClassDef.Get <Car>().SuperClassDef; //---------------Test Result ----------------------- Assert.IsNotNull(superClassDef); }
[Test] // Checks that the read-write rules have not been changed in the class defs public void Test_ReadWriteRules() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- ClassDef classDef = ClassDef.Get <SteeringWheel>(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- //---------------Test Result ----------------------- Assert.AreEqual("WriteNew", classDef.PropDefColIncludingInheritance["SteeringWheelID"].ReadWriteRule.ToString()); Assert.AreEqual("ReadWrite", classDef.PropDefColIncludingInheritance["CarID"].ReadWriteRule.ToString()); }
private static void ConfigureLabel(Label label, string propName) { IUIFormField field = new UIFormField(label.Text, propName) { ClassDef = ClassDef.Get <TBo>() }; var singleValueDef = GetSingleValueDef(propName); label.Text = field.GetLabel(); if (IsCompulsory(singleValueDef)) { SetBoldText(label); } }
public void Test_GetMapperType_WhenControlTypeComboBox_WhenPropTypeIsEnum_ShouldReturnEnumComboBoxMapper() { //---------------Set up test pack------------------- var registry = CreateWinFormsControlMapperRegistry(); var comboBox = new ComboBox {Name = "cmbFakeEnumProp"}; var classDef = ClassDef.Get<FakeBo>(); var propDef = classDef.GetPropDef("FakeEnumProp", false); //---------------Assert Precondition---------------- Assert.IsNotNull(comboBox); Assert.IsTrue(propDef.PropertyType.ToTypeWrapper().IsEnumType()); //---------------Execute Test ---------------------- var mapperType = registry.GetMapperType<FakeBo>(comboBox); //---------------Test Result ----------------------- Assert.AreEqual(typeof(EnumComboBoxMapper), mapperType, "Should be EnumComboBoxMapper"); }
public void Test_Inheritance_SuperClassDef_PropertiesCorrect() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ISuperClassDef superClassDef = ClassDef.Get <Car>().SuperClassDef; //---------------Test Result ----------------------- Assert.AreEqual("TestProject.BO", superClassDef.AssemblyName); Assert.AreEqual("Vehicle", superClassDef.ClassName); Assert.AreEqual("VehicleType", superClassDef.Discriminator); }
public void Test_GetMapperType_WhenComboBox_WhenPropTypeIsLookupList_ShouldReturnLookupComboBoxMapper() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Add(FakeBoWithLookupListProp.GetClassDef()); var registry = CreateWinFormsControlMapperRegistry(); var comboBox = new ComboBox { Name = "cmbLookupListProp" }; var classDef = ClassDef.Get<FakeBoWithLookupListProp>(); var propDef = classDef.GetPropDef("LookupListProp", false); //---------------Assert Precondition---------------- Assert.IsNotNull(comboBox); Assert.IsTrue(propDef.HasLookupList()); //---------------Execute Test ---------------------- var mapperType = registry.GetMapperType<FakeBoWithLookupListProp>(comboBox); //---------------Test Result ----------------------- Assert.AreEqual(typeof(LookupComboBoxMapper), mapperType, "Should be LookupComboBoxMapper"); }
private void SetupReadOnlyGridControl(string gridUiDefName) { ReadOnlyGridControl = _controlFactory.CreateReadOnlyGridControl(); ReadOnlyGridControl.Height = 300; ReadOnlyGridControl.Buttons.Visible = false; ReadOnlyGridControl.FilterControl.Visible = false; IClassDef classDef = ClassDef.Get <TBusinessObject>(); if (!string.IsNullOrEmpty(gridUiDefName)) { ReadOnlyGridControl.Initialise(classDef, gridUiDefName); } AddGridSelectionEvent(); ReadOnlyGridControl.DoubleClickEditsBusinessObject = false; }
[Test] // Checks that the read-write rules have not been changed in the class defs public void Test_ReadWriteRules() { CheckIfTestShouldBeIgnored(); //---------------Set up test pack------------------- ClassDef classDef = ClassDef.Get <Car>(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- //---------------Test Result ----------------------- Assert.AreEqual("ReadWrite", classDef.PropDefColIncludingInheritance["Make"].ReadWriteRule.ToString()); Assert.AreEqual("ReadWrite", classDef.PropDefColIncludingInheritance["Model"].ReadWriteRule.ToString()); Assert.AreEqual("WriteNew", classDef.PropDefColIncludingInheritance["VehicleID"].ReadWriteRule.ToString()); Assert.AreEqual("ReadWrite", classDef.PropDefColIncludingInheritance["VehicleType"].ReadWriteRule.ToString()); Assert.AreEqual("ReadWrite", classDef.PropDefColIncludingInheritance["MaxSpeed"].ReadWriteRule.ToString()); }