public void Test_GetBusinessObjectForProp_ID_WithDatabase() { ClassDef.ClassDefs.Clear(); TestUsingDatabase.SetupDBDataAccessor(); BOWithIntID.DeleteAllBOWithIntID(); IClassDef autoIncClassDef = BOWithIntID.LoadClassDefWithIntID(); IBusinessObject businessObject = GetBusinessObjectStub(); BOPropLookupList boProp = (BOPropLookupList)businessObject.Props[_propDef_int.PropertyName]; BOWithIntID bo1 = new BOWithIntID { TestField = "PropValue", IntID = 55 }; object expectedID = bo1.IntID; bo1.Save(); //---------------Assert Precondition---------------- Assert.AreEqual(typeof(int), _propDef_int.PropertyType); Assert.IsNull(boProp.Value); Assert.IsFalse(bo1.Status.IsNew); Assert.IsNotNull(bo1.IntID); //---------------Execute Test ---------------------- boProp.Value = expectedID; IBusinessObject objectForProp = boProp.GetBusinessObjectForProp(autoIncClassDef); //---------------Test Result ----------------------- Assert.IsNotNull(objectForProp); }
public void Test_AddedChild_UpdatesRelatedPropertiesOnlyWhenParentSaves_DB_CompositeKey() { //---------------Set up test pack------------------- TestUsingDatabase.SetupDBDataAccessor(); Car car = new Car(); car.Save(); ContactPersonCompositeKey contactPerson = new ContactPersonCompositeKey(); contactPerson.PK1Prop1 = TestUtil.GetRandomString(); contactPerson.PK1Prop2 = TestUtil.GetRandomString(); contactPerson.Save(); contactPerson.GetCarsDriven().Add(car); //---------------Assert PreConditions--------------- Assert.AreEqual(contactPerson.PK1Prop1, car.DriverFK1); Assert.AreEqual(contactPerson.PK1Prop2, car.DriverFK2); //---------------Execute Test ---------------------- contactPerson.Save(); FixtureEnvironment.ClearBusinessObjectManager(); Car loadedCar = Broker.GetBusinessObject <Car>(car.ID); //---------------Test Result ----------------------- Assert.AreEqual(contactPerson.PK1Prop1, loadedCar.DriverFK1); Assert.AreEqual(contactPerson.PK1Prop2, loadedCar.DriverFK2); }
public override void SetupTest() { base.SetupTest(); TestUsingDatabase.SetupDBDataAccessor(); OrganisationTestBO.DeleteAllOrganisations(); ContactPersonTestBO.DeleteAllContactPeople(); }
public override void SetupTest() { base.SetupTest(); FixtureEnvironment.ResetBORegistryBusinessObjectManager(); TestUsingDatabase.SetupDBDataAccessor(); OrganisationTestBO.DeleteAllOrganisations(); ContactPersonTestBO.DeleteAllContactPeople(); }
public void SetupFixture() { TestUsingDatabase.SetupDBDataAccessor(); ClassDef.ClassDefs.Clear(); XmlClassLoader loader = new XmlClassLoader(new DtdLoader(), new DefClassFactory()); _itsClassDef = loader.LoadClass (@" <class name=""MyBO"" assembly=""Habanero.Test""> <property name=""MyBoID"" type=""Guid"" /> <property name=""TestProp"" type=""Habanero.Util.LongText"" assembly=""Habanero.Base"" /> <primaryKey> <prop name=""MyBoID"" /> </primaryKey> </class> " ); ClassDef.ClassDefs.Add(_itsClassDef); }
public void PersistSQLparamaterValue_WhenByteArrayNull_WhenMySQL_ShouldNotExist_FIXBUG1741() { //---------------Set up test pack------------------- TestUsingDatabase.SetupDBDataAccessor(); var bo = _classDef.CreateNewBusinessObject(); bo.SetPropertyValue("ByteArrayProp", null); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var sqlCol = new TransactionalBusinessObjectDB(bo, DatabaseConnection.CurrentConnection).GetPersistSql(); var sqlStatement = sqlCol.First(); //IList parameters = sqlStatement.Parameters; DatabaseConnection.CurrentConnection.ExecuteSql(sqlStatement); //---------------Test Result ----------------------- Assert.Pass("If it got here then it is OK"); }
public virtual void Test_SetParent_PersistedChild_FindLoadLookupListError() { //---------------Set up test pack------------------- TestUsingDatabase.SetupDBDataAccessor(); BORegistry.DataAccessor = new DataAccessorDB(); OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation(); GetAssociationRelationship(organisation); ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); //---------------Assert Precondition ----------------------- Assert.IsNotNull(organisation.OrganisationID); //---------------Execute Test ---------------------- contactPerson.Organisation = organisation; //---------------Test Result ----------------------- Assert.AreSame(contactPerson, organisation.ContactPerson); Assert.AreSame(organisation, contactPerson.Organisation); }
public void Test_AddedChild_UpdatesRelatedPropertiesOnlyWhenParentSaves_DB() { //---------------Set up test pack------------------- TestUsingDatabase.SetupDBDataAccessor(); OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation(); SingleRelationship <ContactPersonTestBO> relationship = GetAssociationRelationship(organisation); relationship.OwningBOHasForeignKey = false; ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson(); organisation.ContactPerson = contactPerson; contactPerson.Surname = TestUtil.GetRandomString(); //---------------Execute Test ---------------------- organisation.Save(); FixtureEnvironment.ClearBusinessObjectManager(); ContactPersonTestBO loadedContactPerson = Broker.GetBusinessObject <ContactPersonTestBO>(contactPerson.ID); //---------------Test Result ----------------------- Assert.AreEqual(contactPerson.OrganisationID, loadedContactPerson.OrganisationID); }
public void Test_UpdateSqlStatement_CompositeKey() { //---------------Set up test pack------------------- TestUsingDatabase.SetupDBDataAccessor(); Car car = new Car(); car.Save(); ContactPersonCompositeKey contactPerson = new ContactPersonCompositeKey(); contactPerson.PK1Prop1 = TestUtil.GetRandomString(); contactPerson.PK1Prop2 = TestUtil.GetRandomString(); contactPerson.Save(); contactPerson.GetCarsDriven().Add(car); SingleRelationship <ContactPersonCompositeKey> singleRelationship = car.Relationships.GetSingle <ContactPersonCompositeKey>("Driver"); singleRelationship.SetRelatedObject(contactPerson); IRelationship relationship = contactPerson.Relationships.GetMultiple <Car>("Driver"); var generator = CreateUpdateStatementGenerator(car, DatabaseConfig.MySql); //---------------Assert PreConditions--------------- //---------------Execute Test ---------------------- var sql = generator.GenerateForRelationship(relationship, car); //---------------Test Result ----------------------- var sqlStatements = sql.ToList(); Assert.AreEqual(1, sqlStatements.Count); Assert.AreEqual("UPDATE `car_table` SET `Driver_FK1` = ?Param0, `Driver_FK2` = ?Param1 WHERE `CAR_ID` = ?Param2", sqlStatements[0].Statement.ToString()); Assert.AreEqual(contactPerson.PK1Prop1, sqlStatements[0].Parameters[0].Value); Assert.AreEqual(contactPerson.PK1Prop2, sqlStatements[0].Parameters[1].Value); Assert.AreEqual(car.CarID.ToString("B").ToUpper(), sqlStatements[0].Parameters[2].Value); //---------------Tear Down ------------------------- }
protected override void SetupDataAccess() { TestUsingDatabase.SetupDBDataAccessor(); }
public override void SetupTest() { base.SetupTest(); TestUsingDatabase.SetupDBDataAccessor(); }
private void SetupDataAccessor() { TestUsingDatabase.SetupDBDataAccessor(); }