Tuukka Norri avatar Tuukka Norri committed 5dc73d9

Replaced deprecated methods in unit tests
- Also fixed some bugs.

Comments (0)

Files changed (16)

UnitTests/Sources/BXArbitrarySQLTests.m

 	}
 	
 	{
+		mEntity = [[[mContext databaseObjectModel] entityForTable: @"test"] retain];
+		MKCAssertNotNil (mEntity);
+		
 		NSError *error = nil;
-		mEntity = [[mContext entityForTable: @"test" error: &error] retain];
-		STAssertNotNil (mEntity, [error description]);
-		
 		NSArray *res = [mContext executeFetchForEntity: mEntity withPredicate: nil error: &error];
 		STAssertNotNil (res, [error description]);
 		

UnitTests/Sources/BXModificationTests.m

 @implementation BXModificationTests
 - (void) test1PkeyModification
 {    
-    BXEntityDescription* pkeytest = [mContext entityForTable: @"Pkeytest" error: nil];
+    BXEntityDescription* pkeytest = [[mContext databaseObjectModel] entityForTable: @"Pkeytest"];
     NSError* error = nil;
     MKCAssertNotNil (mContext);
     MKCAssertNotNil (pkeytest);
     NSArray* res = [mContext executeFetchForEntity: pkeytest
                                     withPredicate: [NSPredicate predicateWithFormat: @"Id = 1"]
                                             error: &error];
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (res);
+    STAssertNotNil (res, [error description]);
     
     MKCAssertTrue (1 == [res count]);
     BXDatabaseObject* object = [res objectAtIndex: 0];
     res = [[mContext executeFetchForEntity: pkeytest withPredicate: nil error: &error]
         sortedArrayUsingDescriptors: [NSArray arrayWithObject: 
             [[[NSSortDescriptor alloc] initWithKey: @"Id" ascending: YES] autorelease]]];
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (res);
+    STAssertNotNil (res, [error description]);
 
     MKCAssertTrue (3 == [res count]);
     for (int i = 0; i < 3; i++)
 
 - (void) test2MassUpdateAndDelete
 {
-    BXEntityDescription* updatetest = [mContext entityForTable: @"updatetest" error: nil];
+    BXEntityDescription* updatetest = [[mContext databaseObjectModel] entityForTable: @"updatetest"];
+	MKCAssertNotNil (updatetest);
+	
     NSError* error = nil;
-    
     NSArray* res = [mContext executeFetchForEntity: updatetest withPredicate: nil
                                   returningFaults: NO error: &error];
     NSArray* originalResult = res;
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (res);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (5 == [res count]);
     MKCAssertTrue (5 == [[NSSet setWithArray: [res valueForKey: @"value1"]] count]);
 
 
     //First update just one object
 	id value1Attr = [[updatetest attributesByName] objectForKey: @"value1"];
-    [mContext executeUpdateObject: nil
-						  entity: updatetest 
-                       predicate: predicate
-                  withDictionary: [NSDictionary dictionaryWithObject: number forKey: value1Attr]
-                           error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil ([mContext executeUpdateObject: nil
+										   entity: updatetest 
+										predicate: predicate
+								   withDictionary: [NSDictionary dictionaryWithObject: number forKey: value1Attr]
+											error: &error], [error description]);
     MKCAssertEqualObjects (number, [object valueForKey: @"value1"]);
     MKCAssertTrue (5 == [[NSSet setWithArray: [res valueForKey: @"value1"]] count]);
     
     //Then update multiple objects
     number = [NSNumber numberWithInt: 2];
-    [mContext executeUpdateObject: nil
-						  entity: updatetest 
-                       predicate: nil
-                  withDictionary: [NSDictionary dictionaryWithObject: number forKey: value1Attr]
-                           error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil ([mContext executeUpdateObject: nil
+										   entity: updatetest 
+										predicate: nil
+								   withDictionary: [NSDictionary dictionaryWithObject: number forKey: value1Attr]
+											error: &error], [error description]);
+	
     NSArray* values = [res valueForKey: @"value1"];
     MKCAssertTrue (1 == [[NSSet setWithArray: values] count]);
     MKCAssertEqualObjects (number, [values objectAtIndex: 0]);
     number = [NSNumber numberWithInt: -1];
 	id idattr = [[updatetest attributesByName] objectForKey: @"id"];
     MKCAssertTrue (5 == [[NSSet setWithArray: [res valueForKey: @"id"]] count]);
-    [mContext executeUpdateObject: object
-						  entity: updatetest
-                       predicate: predicate
-                  withDictionary: [NSDictionary dictionaryWithObject: number forKey: idattr]
-                           error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil ([mContext executeUpdateObject: object
+										   entity: updatetest
+										predicate: predicate
+								   withDictionary: [NSDictionary dictionaryWithObject: number forKey: idattr]
+											error: &error], [error description]);
+	
     MKCAssertTrue (5 == [[NSSet setWithArray: [res valueForKey: @"id"]] count]);
     MKCAssertEqualObjects ([object valueForKey: @"id"], number);
     
     //Then delete an object
     predicate = [NSPredicate predicateWithFormat: @"id = -1"];
-    [mContext executeDeleteFromEntity: updatetest withPredicate: predicate error: &error];
-    STAssertNil (error, [error description]);
+    STAssertTrue ([mContext executeDeleteFromEntity: updatetest withPredicate: predicate error: &error], [error description]);
     res = [mContext executeFetchForEntity: updatetest withPredicate: nil
                          returningFaults: NO error: &error];
     MKCAssertTrue (4 == [res count]);
     MKCAssertTrue (0 == [res count]);
     
     //Finally delete all objects
-    [mContext executeDeleteFromEntity: updatetest withPredicate: nil error: &error];
-    STAssertNil (error, [error description]);
+    STAssertTrue ([mContext executeDeleteFromEntity: updatetest withPredicate: nil error: &error], [error description]);
     res = [mContext executeFetchForEntity: updatetest withPredicate: nil
                          returningFaults: NO error: &error];
     MKCAssertTrue (0 == [res count]);
 - (void) test3CreateAndDeleteWithArray
 {	
 	//Fetch a self-updating collection and expect its contents to change.
-    NSError* error = nil;
-    NSArray* array = nil;
-    BXEntityDescription* entity = [[mContext entityForTable: @"test" error: &error] retain];
-	STAssertNotNil (entity, [error description]);
-	array = [mContext executeFetchForEntity: entity withPredicate: nil returningFaults: NO 
-					   updateAutomatically: YES error: &error];
+    BXEntityDescription* entity = [[[mContext databaseObjectModel] entityForTable: @"test"] retain];
+	MKCAssertNotNil (entity);
+	
+    NSError *error = nil;
+	NSArray *array = [mContext executeFetchForEntity: entity withPredicate: nil returningFaults: NO 
+								 updateAutomatically: YES error: &error];
     STAssertNotNil (array, [error description]);
     NSUInteger count = [array count];
     

UnitTests/Sources/BXPredicateTests.m

 	BXDatabaseContext* ctx = [[BXDatabaseContext alloc] initWithDatabaseURI: [self databaseURI]];
 	[ctx setDelegate: self];
 	
-	BXEntityDescription* entity = [ctx entityForTable: @"test" inSchema: @"public" error: NULL];
+	BXEntityDescription* entity = [[ctx databaseObjectModel] entityForTable: @"test" inSchema: @"public"];
+	MKCAssertNotNil (entity);
+	
 	OCMockObject *entityMock = [OCMockObject partialMockForObject: entity];
 	BXAttributeDescription *attr = [BXAttributeDescription attributeWithName: @"id" entity: (id) entityMock];
 	[[[entityMock stub] andReturn: [NSDictionary dictionaryWithObject: attr forKey: @"id"]] attributesByName];

UnitTests/Sources/BXSQLTests.m

 - (void) testDisableEnable
 {
 	NSError* error = nil;
-	[mContext connectSync: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([mContext connectSync: &error], [error description]);
 	
 	BXPGTransactionHandler* handler = [(BXPGInterface *) [mContext databaseInterface] transactionHandler];
 	PGTSConnection* connection = [handler connection];
 - (void) testPrune
 {
 	NSError* error = nil;
-	[mContext connectSync: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([mContext connectSync: &error], [error description]);
 	
 	BXPGTransactionHandler* handler = [(BXPGInterface *) [mContext databaseInterface] transactionHandler];
 	PGTSConnection* connection = [handler connection];

UnitTests/Sources/ConnectTest.m

 - (void) test7NilURI
 {
 	NSError* error = nil;
-	id rval = nil;
-	BXEntityDescription* entity = [ctx entityForTable: @"test" error: &error];
-	rval = [ctx executeFetchForEntity: entity withPredicate: nil error: &error];
+	id fetched = nil;
+	BXEntityDescription* entity = [[ctx databaseObjectModel] entityForTable: @"test"];
+	fetched = [ctx executeFetchForEntity: entity withPredicate: nil error: &error];
 	MKCAssertNotNil (error);
-	rval = [ctx createObjectForEntity: entity withFieldValues: nil error: &error];
+	fetched = [ctx createObjectForEntity: entity withFieldValues: nil error: &error];
 	MKCAssertNotNil (error);
 }
 

UnitTests/Sources/CreateTests.m

 - (void) testCreate
 {
     NSError* error = nil;    
-    BXEntityDescription* entity = [mContext entityForTable: @"test" error: nil];
+    BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: @"test"];
     MKCAssertNotNil (entity);
     
     BXDatabaseObject* object = [mContext createObjectForEntity: entity withFieldValues: nil error: &error];
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (object);
+    STAssertNotNil (object, [error description]);
     [mContext rollback];
 }
 
 - (void) testCreateWithFieldValues
 {
-	BXEntityDescription* entity = [[mContext entityForTable: @"test" error: nil] retain];
+	BXEntityDescription* entity = [[[mContext databaseObjectModel] entityForTable: @"test"] retain];
     MKCAssertNotNil (entity);
 	
 	NSError* error = nil;
 	NSDictionary* values = [NSDictionary dictionaryWithObject: @"test" forKey: @"value"];
 	BXDatabaseObject* object = [mContext createObjectForEntity: entity withFieldValues: values error: &error];
-	STAssertNil (error, [error description]);
-	MKCAssertNotNil (object);
+	STAssertNotNil (object, [error description]);
 	
 	MKCAssertFalse ([object isFaultKey: @"value"]);
 	MKCAssertTrue ([[object valueForKey: @"value"] isEqual: [values valueForKey: @"value"]]);
 	NSString* precomposed = @"åäöÅÄÖ";
 	NSString* decomposed = @"åäöÅÄÖ";
 	
-	BXEntityDescription* entity = [[mContext entityForTable: @"test" error: nil] retain];
+	BXEntityDescription* entity = [[[mContext databaseObjectModel] entityForTable: @"test"] retain];
     MKCAssertNotNil (entity);
 	
 	NSError* error = nil;
 	NSDictionary* values = [NSDictionary dictionaryWithObject: precomposed forKey: @"value"];
 	BXDatabaseObject* object = [mContext createObjectForEntity: entity withFieldValues: values error: &error];
-	STAssertNil (error, [error description]);
-	MKCAssertNotNil (object);
+	STAssertNotNil (object, [error description]);
 	
 	MKCAssertFalse ([object isFaultKey: @"value"]);
 	MKCAssertTrue ([[object valueForKey: @"value"] isEqual: decomposed]);
     NSError* error = nil;
     Class objectClass = [TestObject class];
     
-	BXEntityDescription* entity = [mContext entityForTable: @"test" error: NULL];
+	BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: @"test"];
     MKCAssertNotNil (entity);
 	
     [entity setDatabaseObjectClass: objectClass];
     MKCAssertEqualObjects (objectClass, [entity databaseObjectClass]);
     
     BXDatabaseObject* object = [mContext createObjectForEntity: entity withFieldValues: nil error: &error];
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (object);
+    STAssertNotNil (object, [error description]);
 	
     MKCAssertTrue ([object isKindOfClass: objectClass]);    
     [mContext rollback];
 	[mContext connectSync: NULL];
 	MKCAssertTrue ([mContext isConnected]);
 	
-	BXEntityDescription* test1 = [mContext entityForTable: @"test1" inSchema: @"Fkeytest" error: NULL];
-	BXEntityDescription* test2 = [mContext entityForTable: @"test2" inSchema: @"Fkeytest" error: NULL];
+	BXEntityDescription* test1 = [[mContext databaseObjectModel] entityForTable: @"test1" inSchema: @"Fkeytest"];
+	BXEntityDescription* test2 = [[mContext databaseObjectModel] entityForTable: @"test2" inSchema: @"Fkeytest"];
 	MKCAssertNotNil (test1);
 	MKCAssertNotNil (test2);
 	

UnitTests/Sources/EntityTests.m

 @implementation EntityTests
 - (void) test1ValidName
 {
-	NSError* error = nil;
 	NSString* schemaName = @"Fkeytest";
 	NSString* entityName = @"mtocollectiontest1";
-	BXEntityDescription* entity = [mContext entityForTable: entityName inSchema: schemaName error: &error];
-	STAssertNil (error, [error description]);
+	BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: entityName inSchema: schemaName];
 	MKCAssertNotNil (entity);
 	MKCAssertEqualObjects ([entity name], entityName);
 	MKCAssertEqualObjects ([entity schemaName], schemaName);
 	NSError* error = nil;
 	NSString* schemaName = @"public";
 	NSString* entityName = @"aNonExistentTable";
-	[mContext connectIfNeeded: &error];
-	BXEntityDescription* entity = [mContext entityForTable: entityName inSchema: schemaName error: &error];
-	MKCAssertNotNil (error);
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
+	BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: entityName inSchema: schemaName];
 	MKCAssertNil (entity);
 }
 
 - (void) test3Validation
 {
 	NSError* error = nil;
-	[mContext connectIfNeeded: &error];
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
 	//This entity has fields only some of which are primary key.
-	BXEntityDescription* entity = [mContext entityForTable: @"mtmtest2" inSchema: @"Fkeytest" error: &error];
-	STAssertNotNil (entity, [NSString stringWithFormat: @"Entity was nil (error: %@)", error]);
+	BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: @"mtmtest2" inSchema: @"Fkeytest"];
+	MKCAssertNotNil (entity);
 	
 	//The entity should be validated
 	MKCAssertNotNil ([entity fields]);
 
 - (void) test4Sharing
 {
-	NSError* error = nil;
 	NSString* entityName = @"mtocollectiontest1";
 	NSString* schemaName = @"Fkeytest";
-	BXEntityDescription* entity = [mContext entityForTable: entityName inSchema: schemaName error: &error];
-	STAssertNotNil (entity, [NSString stringWithFormat: @"Entity was nil (error: %@)", error]);
+	BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: entityName inSchema: schemaName];
+	MKCAssertNotNil (entity);
 	
 	BXDatabaseContext* ctx2 = [BXDatabaseContext contextWithDatabaseURI: [mContext databaseURI]];
 	[ctx2 setDelegate: self];
-	BXEntityDescription* entity2 = [ctx2 entityForTable: entityName inSchema: schemaName error: &error];
-	STAssertNotNil (entity, [NSString stringWithFormat: @"Entity was nil (error: %@)", error]);
+	BXEntityDescription* entity2 = [[ctx2 databaseObjectModel] entityForTable: entityName inSchema: schemaName];
+	MKCAssertNotNil (entity2);
 	MKCAssertTrue (entity == entity2);
 }
 
 {
 	[mContext connectSync: NULL];
 	
-	NSError* error = nil;
-	BXEntityDescription* entity = [mContext entityForTable: @"test" error: &error];
-	STAssertNotNil (entity, [error description]);
+	BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: @"test"];
+	MKCAssertNotNil (entity);
 	
 	BXAttributeDescription* attr = [[entity attributesByName] objectForKey: @"xmin"];
 	MKCAssertNotNil (attr);
 
 - (void) test6Hash
 {
-    BXEntityDescription* e1 = [mContext entityForTable: @"test2" inSchema: @"Fkeytest" error: nil];
-    BXEntityDescription* e2 = [mContext entityForTable: @"test2" inSchema: @"Fkeytest" error: nil];
+    BXEntityDescription* e1 = [[mContext databaseObjectModel] entityForTable: @"test2" inSchema: @"Fkeytest"];
+    BXEntityDescription* e2 = [[mContext databaseObjectModel] entityForTable: @"test2" inSchema: @"Fkeytest"];
+	MKCAssertNotNil (e1);
+	MKCAssertNotNil (e2);
 
     NSSet* container3 = [NSSet setWithObject: e1];
     MKCAssertNotNil ([container3 member: e1]);
     MKCAssertEqualObjects (e1, e2);
     
     NSArray* container = [NSArray arrayWithObjects: 
-        [mContext entityForTable: @"mtmrel1"  inSchema: @"Fkeytest" error: nil],
-        [mContext entityForTable: @"mtmtest1" inSchema: @"Fkeytest" error: nil],
-        [mContext entityForTable: @"mtmtest2" inSchema: @"Fkeytest" error: nil],
-        [mContext entityForTable: @"ototest1" inSchema: @"Fkeytest" error: nil],
-        [mContext entityForTable: @"ototest2" inSchema: @"Fkeytest" error: nil],
-        [mContext entityForTable: @"test1"    inSchema: @"Fkeytest" error: nil],
+        [[mContext databaseObjectModel] entityForTable: @"mtmrel1"  inSchema: @"Fkeytest"],
+        [[mContext databaseObjectModel] entityForTable: @"mtmtest1" inSchema: @"Fkeytest"],
+        [[mContext databaseObjectModel] entityForTable: @"mtmtest2" inSchema: @"Fkeytest"],
+        [[mContext databaseObjectModel] entityForTable: @"ototest1" inSchema: @"Fkeytest"],
+        [[mContext databaseObjectModel] entityForTable: @"ototest2" inSchema: @"Fkeytest"],
+        [[mContext databaseObjectModel] entityForTable: @"test1"    inSchema: @"Fkeytest"],
         nil];
     NSSet* container2 = [NSSet setWithArray: container];
 
 
 - (void) test7ViewPkey
 {
-	NSError* error = nil;
-	[mContext connectIfNeeded: &error];
-	BXEntityDescription* entity = [mContext entityForTable: @"test_v" error: &error];
-	STAssertNotNil (entity, [NSString stringWithFormat: @"Entity was nil (error: %@)", error]);
+	NSError *error = nil;
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
+	
+	BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: @"test_v"];
+	MKCAssertNotNil (entity);
 	
 	NSArray* pkeyFields = [entity primaryKeyFields];
 	MKCAssertTrue (1 == [pkeyFields count]);

UnitTests/Sources/FetchTests.m

 - (void) setUp
 {
 	[super setUp];
-	NSError* error = nil;
-    mEntity = [mContext entityForTable: @"test" error: &error];
-	STAssertNil (error, [error description]);
+    mEntity = [[mContext databaseObjectModel] entityForTable: @"test"];
     MKCAssertNotNil (mEntity);
 }
 
 	uriString = [uriString stringByAppendingString: @"/public/test?id,n=1"];
 	NSURL* objectURI = [NSURL URLWithString: uriString];
 	BXDatabaseObjectID* anId = [[[BXDatabaseObjectID alloc] initWithURI: objectURI
-																context: mContext 
-																  error: &error] autorelease];
-	STAssertNil (error, [error description]);
+																context: mContext] autorelease];
+	MKCAssertNotNil (anId);
+	
     BXDatabaseObject* object = [mContext objectWithID: anId error: &error];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (object, [error description]);
+	
     MKCAssertEqualObjects ([object primitiveValueForKey: @"id"], [NSNumber numberWithInt: 1]);
     //if this is not nil, then another test has failed or the database is not in known state
     STAssertEqualObjects ([object valueForKey: @"value"], nil, @"Database is not in known state!");
     NSError* error = nil;
     [mContext connectIfNeeded: nil];
     
-    BXEntityDescription* multicolumnpkey = [mContext entityForTable: @"multicolumnpkey" error: nil];
+    BXEntityDescription* multicolumnpkey = [[mContext databaseObjectModel] entityForTable: @"multicolumnpkey"];
     MKCAssertNotNil (multicolumnpkey);
     NSArray* multicolumnpkeys = [mContext executeFetchForEntity: multicolumnpkey withPredicate: nil error: &error];
-    MKCAssertNotNil (multicolumnpkeys);
+    STAssertNotNil (multicolumnpkeys, [error description]);
     MKCAssertTrue (3 == [multicolumnpkeys  count]);
-    STAssertNil (error, [error description]);
     
     NSSortDescriptor* s1 = [[[NSSortDescriptor alloc] initWithKey: @"id1" ascending: YES] autorelease];
     NSSortDescriptor* s2 = [[[NSSortDescriptor alloc] initWithKey: @"id2" ascending: YES] autorelease];
     NSError* error = nil;
     [mContext connectIfNeeded: nil];
     
-    BXEntityDescription* datetest = [mContext entityForTable: @"datetest" error: nil];
+    BXEntityDescription* datetest = [[mContext databaseObjectModel] entityForTable: @"datetest"];
     MKCAssertNotNil (datetest);
     NSArray* dateobjects = [mContext executeFetchForEntity: datetest withPredicate: nil error: &error];
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (dateobjects);
+    STAssertNotNil (dateobjects, [error description]);
 }
 
 - (void) testQuery
 {
 	NSError* error = nil;
 	NSArray* result = [mContext executeQuery: [NSString stringWithUTF8String: "SELECT * FROM ♨"] error: &error];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (result, [error description]);
 	MKCAssertTrue (3 == [result count]);
 	BXEnumerate (currentRow, e, [result objectEnumerator])
 		MKCAssertTrue (2 == [currentRow count]);
 {
 	NSError* error = nil;
 	unsigned long long count = [mContext executeCommand: [NSString stringWithUTF8String: "UPDATE ♨ SET value = 'test'"] error: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue (0 < count, [error description]);
 	MKCAssertTrue (3 == count);
 }
 
 - (void) testNullValidation
 {
 	NSError* error = nil;
-	BXEntityDescription* person = [mContext entityForTable: @"person" error: &error];
+	BXEntityDescription* person = [[mContext databaseObjectModel] entityForTable: @"person"];
+	MKCAssertNotNil (person);
+	
 	NSArray* people = [mContext executeFetchForEntity: person withPredicate: nil error: &error];
 	BXDatabaseObject* personObject = [people objectAtIndex: 0];
 	
 	
 	error = nil;
 	value = [NSNumber numberWithInt: 1];
-	[personObject validateValue: &value forKey: @"soulmate" error: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([personObject validateValue: &value forKey: @"soulmate" error: &error], [error description]);
 }
 
 - (void) testExclusion
 {
 	NSError* error = nil;
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
+
 	NSString* fieldname = @"value";
-	[mContext connectIfNeeded: &error];
-	STAssertNil (error, [error description]);
 	BXAttributeDescription* property = [[mEntity attributesByName] objectForKey: fieldname];
 	MKCAssertFalse ([property isExcluded]);
 
 	NSArray* result = [mContext executeFetchForEntity: mEntity withPredicate: nil 
 									 excludingFields: [NSArray arrayWithObject: fieldname]
 											   error: &error];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (result, [error description]);
 	MKCAssertTrue ([property isExcluded]);
 	
 	//Quite the same, which object we get
 	BXDatabaseObject* object = [result objectAtIndex: 0]; 
 	MKCAssertTrue (1 == [object isFaultKey: fieldname]);
-	[mContext fireFault: object key: fieldname error: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([mContext fireFault: object key: fieldname error: &error], [error description]);
 	MKCAssertTrue (0 == [object isFaultKey: fieldname]);
 	
 	[mEntity resetAttributeExclusion];
 - (void) testJoin
 {
 	NSError* error = nil;
-	[mContext connectIfNeeded: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
 	
-	BXEntityDescription* person = [mContext entityForTable: @"person" error: &error];
-	STAssertNil (error, [error description]);
+	BXEntityDescription* person = [[mContext databaseObjectModel] entityForTable: @"person"];
+	MKCAssertNotNil (person);
 	
 	NSPredicate* predicate = [NSPredicate predicateWithFormat: @"person_address.address = 'Mannerheimintie 1'"];
 	MKCAssertNotNil (predicate);
 		[NSArray arrayWithObjects: predicate, truePredicate, nil]];
 	
 	NSArray* res = [mContext executeFetchForEntity: person withPredicate: compound error: &error];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (res, [error description]);
 	
 	MKCAssertTrue (1 == [res count]);
 	MKCAssertEqualObjects ([[res objectAtIndex: 0] valueForKey: @"name"], @"nzhuk");
 	[mEntity setDatabaseObjectClass: [FetchTestObject class]];
 	NSArray* res = [mContext executeFetchForEntity: mEntity withPredicate: [NSPredicate predicateWithFormat: @"id = 1"]
 								  returningFaults: NO error: &error];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (res, [error description]);
 	
 	FetchTestObject* object = [res objectAtIndex: 0];
 	MKCAssertFalse ([object isFaultKey: @"value"]);

UnitTests/Sources/ForeignKeyModificationTests.m

 {
 	[super setUp];
     
-    mTest1 		= [[mContext entityForTable: @"test1" inSchema: @"Fkeytest" error: nil] retain];
-    mTest2 		= [[mContext entityForTable: @"test2" inSchema: @"Fkeytest" error: nil] retain];
-    mOtotest1 	= [[mContext entityForTable: @"ototest1" inSchema: @"Fkeytest" error: nil] retain];
-    mOtotest2 	= [[mContext entityForTable: @"ototest2" inSchema: @"Fkeytest" error: nil] retain];
-    mMtmtest1 	= [[mContext entityForTable: @"mtmtest1" inSchema: @"Fkeytest" error: nil] retain];
-    mMtmtest2 	= [[mContext entityForTable: @"mtmtest2" inSchema: @"Fkeytest" error: nil] retain];
+    mTest1 		= [[[mContext databaseObjectModel] entityForTable: @"test1" inSchema: @"Fkeytest"] retain];
+    mTest2 		= [[[mContext databaseObjectModel] entityForTable: @"test2" inSchema: @"Fkeytest"] retain];
+    mOtotest1 	= [[[mContext databaseObjectModel] entityForTable: @"ototest1" inSchema: @"Fkeytest"] retain];
+    mOtotest2 	= [[[mContext databaseObjectModel] entityForTable: @"ototest2" inSchema: @"Fkeytest"] retain];
+    mMtmtest1 	= [[[mContext databaseObjectModel] entityForTable: @"mtmtest1" inSchema: @"Fkeytest"] retain];
+    mMtmtest2 	= [[[mContext databaseObjectModel] entityForTable: @"mtmtest2" inSchema: @"Fkeytest"] retain];
 
     MKCAssertNotNil (mTest1);
     MKCAssertNotNil (mTest2);
     MKCAssertNotNil (mMtmtest1);
     MKCAssertNotNil (mMtmtest2);
 
-    mTest1v		= [[mContext entityForTable: @"test1_v" inSchema: @"Fkeytest" error: nil] retain];
-    mTest2v		= [[mContext entityForTable: @"test2_v" inSchema: @"Fkeytest" error: nil] retain];
-    mOtotest1v	= [[mContext entityForTable: @"ototest1_v" inSchema: @"Fkeytest" error: nil] retain];
-    mOtotest2v	= [[mContext entityForTable: @"ototest2_v" inSchema: @"Fkeytest" error: nil] retain];
-    mMtmtest1v	= [[mContext entityForTable: @"mtmtest1_v" inSchema: @"Fkeytest" error: nil] retain];
-    mMtmtest2v	= [[mContext entityForTable: @"mtmtest2_v" inSchema: @"Fkeytest" error: nil] retain];
-	mMtmrel1	= [[mContext entityForTable: @"mtmrel1" inSchema: @"Fkeytest" error: nil] retain];
+    mTest1v		= [[[mContext databaseObjectModel] entityForTable: @"test1_v" inSchema: @"Fkeytest"] retain];
+    mTest2v		= [[[mContext databaseObjectModel] entityForTable: @"test2_v" inSchema: @"Fkeytest"] retain];
+    mOtotest1v	= [[[mContext databaseObjectModel] entityForTable: @"ototest1_v" inSchema: @"Fkeytest"] retain];
+    mOtotest2v	= [[[mContext databaseObjectModel] entityForTable: @"ototest2_v" inSchema: @"Fkeytest"] retain];
+    mMtmtest1v	= [[[mContext databaseObjectModel] entityForTable: @"mtmtest1_v" inSchema: @"Fkeytest"] retain];
+    mMtmtest2v	= [[[mContext databaseObjectModel] entityForTable: @"mtmtest2_v" inSchema: @"Fkeytest"] retain];
+	mMtmrel1	= [[[mContext databaseObjectModel] entityForTable: @"mtmrel1" inSchema: @"Fkeytest"] retain];
     
     MKCAssertNotNil (mTest1v);
     MKCAssertNotNil (mTest2v);
     NSArray* res = [mContext executeFetchForEntity: manyEntity
                                     withPredicate: [NSPredicate predicateWithFormat: @"id = 1"]
                                             error: &error];
-    MKCAssertNotNil (res);
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (1 == [res count]);
     BXDatabaseObject* foreignObject = [res objectAtIndex: 0];
     MKCAssertTrue ([[foreignObject objectID] entity] == manyEntity);
     res = [mContext executeFetchForEntity: oneEntity
 						   withPredicate: [NSPredicate predicateWithFormat: @"id = 2"]
 								   error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (1 == [res count]);
     BXDatabaseObject* object = [res objectAtIndex: 0];
     MKCAssertTrue ([[object objectID] entity] == oneEntity);
     NSError* error = nil;
         
     BXDatabaseObject* object = [mContext createObjectForEntity: oneEntity withFieldValues: nil error: &error];
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (object);
+    STAssertNotNil (object, [error description]);
 	//If the set proxy wasn't created earlier, here it will be. This might be useful for debugging.
     STAssertTrue (0 == [[object valueForKey: [manyEntity name]] count], [[object valueForKey: [manyEntity name]] description]);
     MKCAssertTrue ([[object objectID] entity] == oneEntity);
     for (int i = 0; i < count; i++)
     {
         BXDatabaseObject* foreignObject = [mContext createObjectForEntity: manyEntity withFieldValues: nil error: &error];
-        STAssertNil (error, [error description]);
-        MKCAssertNotNil (foreignObject);
+        STAssertNotNil (foreignObject, [error description]);
         MKCAssertTrue ([[foreignObject objectID] entity] == manyEntity);
         [foreignObjects addObject: foreignObject];
     }
     //Change a reference in entity1 and entity2
     
     NSError* error = nil;
-	[mContext connectSync: &error];
-    STAssertNil (error, [error description]);
+	STAssertTrue ([mContext connectSync: &error], [error description]);
 	
     MKCAssertFalse ([[[entity1 relationshipsByName] objectForKey: [entity2 name]] isToMany]);
     MKCAssertFalse ([[[entity2 relationshipsByName] objectForKey: [entity1 name]] isToMany]);
     NSArray* res = [mContext executeFetchForEntity: entity1
                                     withPredicate: [NSPredicate predicateWithFormat: @"id = 1"]
                                             error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (1 == [res count]);
     BXDatabaseObject* object = [res objectAtIndex: 0];
     MKCAssertTrue ([[object objectID] entity] == entity1);
     res = [mContext executeFetchForEntity: entity2
                            withPredicate: [NSPredicate predicateWithFormat: @"id = 1"]
                                    error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (1 == [res count]);
     BXDatabaseObject* foreignObject1 = [res objectAtIndex: 0];
     MKCAssertTrue ([[foreignObject1 objectID] entity] == entity2);
                                     withPredicate: [NSPredicate predicateWithFormat: @"id = 1"]
                                             error: &error];
     
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     return [res objectAtIndex: 0];
 }
 
     NSArray* res = [mContext executeFetchForEntity: mTest1
                                     withPredicate: predicate
                                             error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (1 == [res count]);
     BXDatabaseObject* object = [res objectAtIndex: 0];
     //Create a self-updating container to see if it interferes with object creation.
 							[object primitiveValueForKey: @"id"], @"fkt1id",
 							@"test", @"value",
 							nil];
-    [mContext createObjectForEntity: mTest2 withFieldValues: values error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil ([mContext createObjectForEntity: mTest2 withFieldValues: values error: &error], [error description]);
     
     collection = nil;
     [mContext rollback];

UnitTests/Sources/ForeignKeyTests.m

 {
 	[super setUp];
 
-    mTest1 = [mContext entityForTable: @"test1" inSchema: @"Fkeytest" error: nil];
-    mTest2 = [mContext entityForTable: @"test2" inSchema: @"Fkeytest" error: nil];
-    mOtotest1 = [mContext entityForTable: @"ototest1" inSchema: @"Fkeytest" error: nil];
-    mOtotest2 = [mContext entityForTable: @"ototest2" inSchema: @"Fkeytest" error: nil];
-    mMtmtest1 = [mContext entityForTable: @"mtmtest1" inSchema: @"Fkeytest" error: nil];
-    mMtmtest2 = [mContext entityForTable: @"mtmtest2" inSchema: @"Fkeytest" error: nil];
+    mTest1 = [[mContext databaseObjectModel] entityForTable: @"test1" inSchema: @"Fkeytest"];
+    mTest2 = [[mContext databaseObjectModel] entityForTable: @"test2" inSchema: @"Fkeytest"];
+    mOtotest1 = [[mContext databaseObjectModel] entityForTable: @"ototest1" inSchema: @"Fkeytest"];
+    mOtotest2 = [[mContext databaseObjectModel] entityForTable: @"ototest2" inSchema: @"Fkeytest"];
+    mMtmtest1 = [[mContext databaseObjectModel] entityForTable: @"mtmtest1" inSchema: @"Fkeytest"];
+    mMtmtest2 = [[mContext databaseObjectModel] entityForTable: @"mtmtest2" inSchema: @"Fkeytest"];
 
     MKCAssertNotNil (mTest1);
     MKCAssertNotNil (mTest2);
     MKCAssertNotNil (mMtmtest1);
     MKCAssertNotNil (mMtmtest2);
 
-    mTest1v = [mContext entityForTable: @"test1_v" inSchema: @"Fkeytest" error: nil];
-    mTest2v = [mContext entityForTable: @"test2_v" inSchema: @"Fkeytest" error: nil];
-    mOtotest1v = [mContext entityForTable: @"ototest1_v" inSchema: @"Fkeytest" error: nil];
-    mOtotest2v = [mContext entityForTable: @"ototest2_v" inSchema: @"Fkeytest" error: nil];
-    mMtmtest1v = [mContext entityForTable: @"mtmtest1_v" inSchema: @"Fkeytest" error: nil];
-    mMtmtest2v = [mContext entityForTable: @"mtmtest2_v" inSchema: @"Fkeytest" error: nil];
-	mMtmrel1 = [mContext entityForTable: @"mtmrel1" inSchema: @"Fkeytest" error: nil];
+    mTest1v = [[mContext databaseObjectModel] entityForTable: @"test1_v" inSchema: @"Fkeytest"];
+    mTest2v = [[mContext databaseObjectModel] entityForTable: @"test2_v" inSchema: @"Fkeytest"];
+    mOtotest1v = [[mContext databaseObjectModel] entityForTable: @"ototest1_v" inSchema: @"Fkeytest"];
+    mOtotest2v = [[mContext databaseObjectModel] entityForTable: @"ototest2_v" inSchema: @"Fkeytest"];
+    mMtmtest1v = [[mContext databaseObjectModel] entityForTable: @"mtmtest1_v" inSchema: @"Fkeytest"];
+    mMtmtest2v = [[mContext databaseObjectModel] entityForTable: @"mtmtest2_v" inSchema: @"Fkeytest"];
+	mMtmrel1 = [[mContext databaseObjectModel] entityForTable: @"mtmrel1" inSchema: @"Fkeytest"];
     
     MKCAssertNotNil (mTest1v);
     MKCAssertNotNil (mTest2v);
     {
         NSPredicate* predicate = [NSPredicate predicateWithFormat: @"id = %d", i];
         MKCAssertNotNil (predicate);
+		
         NSArray* res = [mContext executeFetchForEntity: manyEntity
                                         withPredicate: predicate
                                                 error: &error];
-        STAssertNil (error, [error description]);
+        STAssertNotNil (res, [error description]);
         MKCAssertTrue (1 == [res count]);
     
         BXDatabaseObject* object = [res objectAtIndex: 0];
     NSArray* res = [mContext executeFetchForEntity: oneEntity
                                     withPredicate: predicate
                                             error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (1 == [res count]);
     BXDatabaseObject* object = [res objectAtIndex: 0];
 
     MKCAssertTrue ([rel isToMany]);
         
     NSSet* foreignObjects = [rel targetForObject: object error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (foreignObjects, [error description]);
     MKCAssertTrue (2 == [foreignObjects count]);
     NSArray* values = [foreignObjects valueForKey: @"value"];
     MKCAssertTrue ([values containsObject: @"21"]);
         MKCAssertTrue ([[currentObject objectID] entity] == manyEntity);
 
     foreignObjects = [object valueForKey: [manyEntity name]];
-    STAssertNil (error, [error description]);
     MKCAssertTrue (2 == [foreignObjects count]);
     values = [foreignObjects valueForKey: @"value"];
     MKCAssertTrue ([values containsObject: @"21"]);
 {
     NSError* error = nil;
 	
-	[mContext connectIfNeeded: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
 	
     BXRelationshipDescription* foobar = [[entity1 relationshipsByName] objectForKey: [entity2 name]];
     MKCAssertNotNil (foobar);
     NSArray* res = [mContext executeFetchForEntity: entity1 
                                     withPredicate: [NSPredicate predicateWithFormat: @"1 <= id && id <= 2"]
                                             error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (2 == [res count]);
     for (int i = 0; i < 2; i++)
     {
         
         BXDatabaseObject* foreignObject  = [object primitiveValueForKey: [entity2 name]];
         BXDatabaseObject* foreignObject2 = [foobar targetForObject: object error: &error];
-        STAssertNil (error, [error description]);
+        STAssertNotNil (foreignObject2, [error description]);
         
         BXDatabaseObject* object2 = [foreignObject primitiveValueForKey: [entity1 name]];
         BXDatabaseObject* object3 = [[foobar inverseRelationship] targetForObject: foreignObject error: &error];
-        STAssertNil (error, [error description]);
+        STAssertNotNil (object3, [error description]);
         
         MKCAssertTrue ([[foreignObject  objectID] entity] == entity2);
         MKCAssertTrue ([[foreignObject2 objectID] entity] == entity2);
     res = [mContext executeFetchForEntity: entity2
                            withPredicate: [NSPredicate predicateWithFormat: @"id = 3"]
                                    error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (1 == [res count]);
     BXDatabaseObject* object = [res objectAtIndex: 0];
     MKCAssertNil ([object valueForKey: [entity1 name]]);
 {
     NSError* error = nil;
     NSArray* res = [mContext executeFetchForEntity: entity1 withPredicate: nil error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (4 == [res count]);
     
     NSSet* expected1 = [NSSet setWithObjects: @"a1", @"b1", @"c1", nil];
 	NSArray* res = [mContext executeFetchForEntity: entity
 									withPredicate: [NSPredicate predicateWithFormat: @"id = 1"]
 											error: &error];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (res, [error description]);
 	BXDatabaseObject* object = [res objectAtIndex: 0];
 	NSSet* helperObjects = [object primitiveValueForKey: @"mtmrel1"];
 	MKCAssertTrue (3 == [helperObjects count]);

UnitTests/Sources/MTMCollectionTest.m

 {
 	[super setUp];
     
-    mMtmtest1 = [mContext entityForTable: @"mtmtest1" inSchema: @"Fkeytest" error: nil];
-    mMtmtest2 = [mContext entityForTable: @"mtmtest2" inSchema: @"Fkeytest" error: nil];
+    mMtmtest1 = [[mContext databaseObjectModel] entityForTable: @"mtmtest1" inSchema: @"Fkeytest"];
+    mMtmtest2 = [[mContext databaseObjectModel] entityForTable: @"mtmtest2" inSchema: @"Fkeytest"];
     MKCAssertNotNil (mMtmtest1);
     MKCAssertNotNil (mMtmtest2);
     
-    mMtmtest1v = [mContext entityForTable: @"mtmtest1_v" inSchema: @"Fkeytest" error: nil];
-    mMtmtest2v = [mContext entityForTable: @"mtmtest2_v" inSchema: @"Fkeytest" error: nil];
+    mMtmtest1v = [[mContext databaseObjectModel] entityForTable: @"mtmtest1_v" inSchema: @"Fkeytest"];
+    mMtmtest2v = [[mContext databaseObjectModel] entityForTable: @"mtmtest2_v" inSchema: @"Fkeytest"];
     MKCAssertNotNil (mMtmtest1v);
     MKCAssertNotNil (mMtmtest2v);
 }
 	
     //Execute a fetch
     NSArray* res = [mContext executeFetchForEntity: entity1
-                                    withPredicate: nil error: &error];
-	STAssertNil (error, [error description]);
+									 withPredicate: nil 
+											 error: &error];
+	STAssertNotNil (res, [error description]);
     MKCAssertTrue (4 == [res count]);
     
     //Get an object from the result
     MKCAssertTrue ([foreignObjects isEqualToSet: foreignObjects2]);
     
     //Get the objects from the second table
-    NSSet* objects2 = [NSSet setWithArray: [mContext executeFetchForEntity: entity2
-                                                            withPredicate: [NSPredicate predicateWithFormat:  @"value2 != 'd2'"]
-                                                                    error: &error]];
-    STAssertNil (error, [error description]);
+	NSArray *res2 = [mContext executeFetchForEntity: entity2
+									  withPredicate: [NSPredicate predicateWithFormat:  @"value2 != 'd2'"]
+											  error: &error];
+    STAssertNotNil (res2, [error description]);
+    NSSet *objects2 = [NSSet setWithArray: res2];
     MKCAssertTrue (3 == [objects2 count]);
     
     NSMutableSet* mock = [NSMutableSet set];

UnitTests/Sources/MTOCollectionTest.m

 {
 	[super setUp];
 
-    mMtocollectiontest1 = [mContext entityForTable: @"mtocollectiontest1" inSchema: @"Fkeytest" error: nil];
-    mMtocollectiontest2 = [mContext entityForTable: @"mtocollectiontest2" inSchema: @"Fkeytest" error: nil];
+    mMtocollectiontest1 = [[mContext databaseObjectModel] entityForTable: @"mtocollectiontest1" inSchema: @"Fkeytest"];
+    mMtocollectiontest2 = [[mContext databaseObjectModel] entityForTable: @"mtocollectiontest2" inSchema: @"Fkeytest"];
     MKCAssertNotNil (mMtocollectiontest1);
     MKCAssertNotNil (mMtocollectiontest2);
     
-    mMtocollectiontest1v = [mContext entityForTable: @"mtocollectiontest1_v" inSchema: @"Fkeytest" error: nil];
-    mMtocollectiontest2v = [mContext entityForTable: @"mtocollectiontest2_v" inSchema: @"Fkeytest" error: nil];
+    mMtocollectiontest1v = [[mContext databaseObjectModel] entityForTable: @"mtocollectiontest1_v" inSchema: @"Fkeytest"];
+    mMtocollectiontest2v = [[mContext databaseObjectModel] entityForTable: @"mtocollectiontest2_v" inSchema: @"Fkeytest"];
     MKCAssertNotNil (mMtocollectiontest1v);
     MKCAssertNotNil (mMtocollectiontest2v);
 }
         
     //Execute a fetch
     NSArray* res = [mContext executeFetchForEntity: oneEntity
-                                    withPredicate: nil error: &error];
-    STAssertNil (error, [error description]);
+									 withPredicate: nil 
+											 error: &error];
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (2 == [res count]);
     
     //Get an object from the result
     MKCAssertTrue ([foreignObjects isEqualToSet: foreignObjects2]);
     
     //Get the objects from the second table
-    NSSet* objects2 = [NSSet setWithArray: [mContext executeFetchForEntity: manyEntity
-                                                            withPredicate: nil error: &error]];
-    STAssertNil (error, [error description]);
+	NSArray *res2 = [mContext executeFetchForEntity: manyEntity
+									  withPredicate: nil 
+											  error: &error];
+    STAssertNotNil (res2, [error description]);
+    NSSet* objects2 = [NSSet setWithArray: res2];
     MKCAssertTrue (3 == [objects2 count]);
     
     //Set the referenced objects. The self-updating collection should get notified when objects are added.
     //Execute a fetch
     NSArray* res = [mContext executeFetchForEntity: oneEntity
                                     withPredicate: nil error: &error];
-    STAssertNil (error, [error description]);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (2 == [res count]);
     
     //Get an object from the result
     MKCAssertTrue ([foreignObjects isEqualToSet: foreignObjects2]);
     
     //Get the objects from the second table
-    NSSet* objects2 = [NSSet setWithArray: [mContext executeFetchForEntity: manyEntity
-                                                            withPredicate: nil error: &error]];
-    STAssertNil (error, [error description]);
+	NSArray *res2 = [mContext executeFetchForEntity: manyEntity
+									  withPredicate: nil 
+											  error: &error];
+    STAssertNotNil (res2, [error description]);
+    NSSet* objects2 = [NSSet setWithArray: res2];
     MKCAssertTrue (3 == [objects2 count]);
     
     NSMutableSet* mock = [NSMutableSet set];

UnitTests/Sources/ObjectIDTests.m

 @implementation ObjectIDTests
 - (void) testObjectIDWithURI
 {
-	NSError* error = nil;
-	BXEntityDescription* entity = [mContext entityForTable: @"test" inSchema: @"public" error: &error];
-	STAssertNotNil (entity, [NSString stringWithFormat: @"Entity was nil (error: %@)", error]);
+	BXEntityDescription* entity = [[mContext databaseObjectModel] entityForTable: @"test" inSchema: @"public"];
+	MKCAssertNotNil (entity);
 	
+	NSError *error = nil;
 	BXDatabaseObject* object = [[mContext executeFetchForEntity: entity 
 											 withPredicate: [NSPredicate predicateWithFormat: @"id == 1"]
 													 error: &error] objectAtIndex: 0];
 	BXDatabaseContext* ctx2 = [BXDatabaseContext contextWithDatabaseURI: [mContext databaseURI]];
 	[ctx2 setDelegate: self];
 	BXDatabaseObjectID* objectID2 = [[[BXDatabaseObjectID alloc] initWithURI: uri context: ctx2 error: &error] autorelease];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (objectID2, [error description]);
 	MKCAssertEqualObjects (objectID, objectID2);
 	
 	BXDatabaseObject* fault = [[ctx2 faultsWithIDs: [NSArray arrayWithObject: objectID2]] objectAtIndex: 0];
 	NSError* error = nil;
 	NSURL* uri = [NSURL URLWithString: @"/public/test?id,n=12345" relativeToURL: [mContext databaseURI]];
 	BXDatabaseObjectID* anId = [[[BXDatabaseObjectID alloc] initWithURI: uri context: mContext error: &error] autorelease];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (anId, [error description]);
 	
-	[mContext connectIfNeeded: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
 	
 	BXDatabaseObject* object = [mContext objectWithID: anId error: &error];
 	MKCAssertNil (object);
 	NSError* error = nil;
 	NSURL* uri = [NSURL URLWithString: @"/public/test?id,n=1" relativeToURL: [mContext databaseURI]];
 	BXDatabaseObjectID* anId = [[[BXDatabaseObjectID alloc] initWithURI: uri context: mContext error: &error] autorelease];
-	STAssertNil (error, [error description]);
+	STAssertNotNil (anId, [error description]);
 	
-	[mContext connectIfNeeded: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
 	
 	BXDatabaseObject* object = [mContext objectWithID: anId error: &error];
-	MKCAssertNotNil (object);
-	STAssertNil (error, [error description]);
+	STAssertNotNil (object, [error description]);
 }
 
 - (void) testObjectIDFromAnotherContext
 {
 	BXDatabaseContext* ctx2 = [[[BXDatabaseContext alloc] initWithDatabaseURI: [mContext databaseURI]] autorelease];
 	[ctx2 setDelegate: self];
-	NSError* error = nil;
 	MKCAssertNotNil (ctx2);
 	
-	BXEntityDescription* entity = [ctx2 entityForTable: @"test" inSchema: @"public" error: &error];
+	BXEntityDescription* entity = [[ctx2 databaseObjectModel] entityForTable: @"test" inSchema: @"public"];
+	MKCAssertNotNil (entity);
+	
+	NSError *error = nil;
 	id objectArray = [ctx2 executeFetchForEntity: entity 
 						  		   withPredicate: [NSPredicate predicateWithFormat: @"id == 1"]
 								 		   error: &error];
-	STAssertNil (error, [error description]);
-	MKCAssertNotNil (objectArray);
+	STAssertNotNil (objectArray, [error description]);
 	
 	BXDatabaseObjectID* anId = (id) [[objectArray objectAtIndex: 0] objectID];
 	MKCAssertNotNil (anId);
 	
-	[mContext connectIfNeeded: &error];
-	STAssertNil (error, [error description]);
+	STAssertTrue ([mContext connectIfNeeded: &error], [error description]);
 	
 	BXDatabaseObject* anObject = [mContext objectWithID: anId error: &error];
-	STAssertNil (error, [error description]);
-	MKCAssertNotNil (anObject);
+	STAssertNotNil (anObject, [error description]);
 	
 	[ctx2 disconnect];
 }

UnitTests/Sources/PropagatedModificationTests.m

     context = [[BXDatabaseContext alloc] initWithDatabaseURI: [self databaseURI]];
 	[context setAutocommits: NO];
 	NSError* error = nil;
-    entity = [context entityForTable: @"test" error: &error];
-	STAssertNil (error, [error description]);
+    entity = [[context databaseObjectModel] entityForTable: @"test"];
     MKCAssertNotNil (entity);
 }
 
     NSString* oldValue = nil;
     [context setAutocommits: YES];
 
-    BXEntityDescription* viewEntity = [context entityForTable: @"test_v" error: nil];
+    BXEntityDescription* viewEntity = [[context databaseObjectModel] entityForTable: @"test_v"];
+	MKCAssertNotNil (viewEntity);
 
     NSPredicate* predicate = [NSPredicate predicateWithFormat: @"id = 1"];
     MKCAssertNotNil (predicate);
     
     NSError* error = nil;
     NSArray* res = [context executeFetchForEntity: entity withPredicate: predicate error: &error];
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (res);
+    STAssertNotNil (res, [error description]);
     MKCAssertTrue (1 == [res count]);
     
     NSArray* res2 = [context executeFetchForEntity: viewEntity withPredicate: predicate error: &error];
-    STAssertNil (error, [error description]);
-    MKCAssertNotNil (res);
-    MKCAssertTrue (1 == [res count]);
+    STAssertNotNil (res2, [error description]);
+    MKCAssertTrue (1 == [res2 count]);
     
     BXDatabaseObject* object = [res objectAtIndex: 0];
     BXDatabaseObject* viewObject = [res2 objectAtIndex: 0];

UnitTests/Sources/ToOneChangeNotificationTests.m

 	mReceivedForB2 = 0;
 	
 	[mContext connectSync: NULL];
-	mTest1 = [[mContext entityForTable: @"test1" inSchema: @"Fkeytest" error: NULL] retain];
-	mTest2 = [[mContext entityForTable: @"test2" inSchema: @"Fkeytest" error: NULL] retain];
+	mTest1 = [[[mContext databaseObjectModel] entityForTable: @"test1" inSchema: @"Fkeytest"] retain];
+	mTest2 = [[[mContext databaseObjectModel] entityForTable: @"test2" inSchema: @"Fkeytest"] retain];
 }
 
 
 {
 	NSPredicate* p1 = [NSPredicate predicateWithFormat: @"id == 1"];
 	NSPredicate* p2 = [NSPredicate predicateWithFormat: @"id == 3"];
-	BXEntityDescription* ototest1 = [mContext entityForTable: @"ototest1" inSchema: @"Fkeytest" error: NULL];
-	BXEntityDescription* ototest2 = [mContext entityForTable: @"ototest2" inSchema: @"Fkeytest" error: NULL];
+	BXEntityDescription* ototest1 = [[mContext databaseObjectModel] entityForTable: @"ototest1" inSchema: @"Fkeytest"];
+	BXEntityDescription* ototest2 = [[mContext databaseObjectModel] entityForTable: @"ototest2" inSchema: @"Fkeytest"];
 	NSArray* r1 = [mContext executeFetchForEntity: ototest1 withPredicate: p1 error: NULL];
 	NSArray* r2 = [mContext executeFetchForEntity: ototest2 withPredicate: p2 error: NULL];
 	

UnitTests/Sources/UndoTests.m

     const unsigned int objectId = 5;
 	[mContext connectSync: NULL];
     NSUndoManager* undoManager = [mContext undoManager];
-    BXEntityDescription* updatetest = [mContext entityForTable: @"updatetest" error: nil];
+    BXEntityDescription* updatetest = [[mContext databaseObjectModel] entityForTable: @"updatetest"];
 
     MKCAssertNotNil (undoManager);
     MKCAssertNotNil (updatetest);
 	const unsigned int objectId = 1;
     [mContext connectIfNeeded: nil];
     NSUndoManager* undoManager = [mContext undoManager];
-    BXEntityDescription* test1 = [mContext entityForTable: @"test1" inSchema: @"Fkeytest" error: nil];
+    MKCAssertNotNil (undoManager);	
+
+    BXEntityDescription* test1 = [[mContext databaseObjectModel] entityForTable: @"test1" inSchema: @"Fkeytest"];
+	MKCAssertNotNil (test1);
+
     BXDatabaseObject* object = [self objectWithId: objectId entity: test1];
 
-    MKCAssertNotNil (undoManager);	
     MKCAssertNotNil (object);
     
     NSMutableSet* foreignObjects = [object primitiveValueForKey: @"test2"];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.