-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added remove() function tests to the Collection, DB and Wire. Tests f…
…or Wire are missing, pending a refactor here. Added makeRemoveOpDeleteMessage() and tests for MessageFactory. Removed an unnecessary endian setting in OpInsert. The remove() method is now working. Signed-off-by: Omar Gonzalez <omar@almerblank.com>
- Loading branch information
Showing
8 changed files
with
184 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package flexUnitTests.as3.mongo.db | ||
{ | ||
import as3.mongo.db.document.Document; | ||
import as3.mongo.wire.Wire; | ||
|
||
import mockolate.received; | ||
import mockolate.runner.MockolateRule; | ||
|
||
import org.flexunit.assertThat; | ||
|
||
public class DB_removeTests | ||
{ | ||
[Rule] | ||
public var mocks:MockolateRule = new MockolateRule(); | ||
|
||
[Mock(inject = "true", type = "nice")] | ||
public var mockWire:Wire; | ||
|
||
private var _db:TestDB; | ||
private var _testCollectionName:String = "aCollection"; | ||
private var _testSelector:Document = new Document(); | ||
private var _testDatabaseName:String = "aDatabaseName"; | ||
|
||
[Before] | ||
public function setUp():void | ||
{ | ||
_db = new TestDB(_testDatabaseName, "host", 27017); | ||
_db.mockWire = mockWire; | ||
} | ||
|
||
[After] | ||
public function tearDown():void | ||
{ | ||
_db = null; | ||
} | ||
|
||
[Test] | ||
public function remove_aDocumentInstanceIsPassedIn_removedInvokedOnWire():void | ||
{ | ||
_db.remove(_testCollectionName, _testSelector); | ||
|
||
assertThat(mockWire, received().method("remove").args(_testDatabaseName, _testCollectionName, _testSelector).once()); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
tests-src/flexUnitTests/as3/mongo/db/collection/Collection_removeTests.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package flexUnitTests.as3.mongo.db.collection | ||
{ | ||
import as3.mongo.db.DB; | ||
import as3.mongo.db.collection.Collection; | ||
import as3.mongo.db.document.Document; | ||
|
||
import mockolate.received; | ||
import mockolate.runner.MockolateRule; | ||
|
||
import org.flexunit.assertThat; | ||
|
||
public class Collection_removeTests | ||
{ | ||
[Rule] | ||
public var mocks:MockolateRule = new MockolateRule(); | ||
|
||
[Mock(inject = "true", type = "nice")] | ||
public var mockDB:DB; | ||
|
||
private var _collection:Collection; | ||
|
||
[Before] | ||
public function setUp():void | ||
{ | ||
_collection = new Collection("aCollection", mockDB); | ||
} | ||
|
||
[After] | ||
public function tearDown():void | ||
{ | ||
_collection = null; | ||
} | ||
|
||
[Test] | ||
public function remove_aDocumentInstanceIsPassedIn_removeInvokedOnDB():void | ||
{ | ||
const testDoc:Document = new Document(); | ||
_collection.remove(testDoc); | ||
|
||
assertThat(mockDB, received().method("remove").args("aCollection", testDoc).once()); | ||
} | ||
|
||
[Test(expects = "as3.mongo.error.MongoError")] | ||
public function remove_aNullObjectIsPassedIn_throwsMongoError():void | ||
{ | ||
_collection.remove(null); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...rc/flexUnitTests/as3/mongo/wire/messages/MessageFactory_makeRemoveOpDeleteMessageTests.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package flexUnitTests.as3.mongo.wire.messages | ||
{ | ||
import as3.mongo.db.document.Document; | ||
import as3.mongo.wire.messages.MessageFactory; | ||
import as3.mongo.wire.messages.client.OpDelete; | ||
|
||
import org.flexunit.asserts.assertEquals; | ||
import org.flexunit.asserts.assertTrue; | ||
|
||
public class MessageFactory_makeRemoveOpDeleteMessageTests | ||
{ | ||
|
||
private var _messageFactory:MessageFactory; | ||
private var _opDelete:OpDelete; | ||
private var _testDBName:String = "aDBName"; | ||
private var _testCollectionName:String = "aCollectionName"; | ||
private var _testSelector:Document = new Document(); | ||
private var _testFullCollectionName:String = "aDBName.aCollectionName"; | ||
|
||
[Before] | ||
public function setUp():void | ||
{ | ||
_messageFactory = new MessageFactory(); | ||
|
||
_opDelete = _messageFactory.makeRemoveOpDeleteMessage(_testDBName, _testCollectionName, _testSelector); | ||
} | ||
|
||
[After] | ||
public function tearDown():void | ||
{ | ||
_messageFactory = null; | ||
} | ||
|
||
[Test] | ||
public function makeRemoveOpDeleteMessage_validInputs_returnsOpDeleteInstance():void | ||
{ | ||
assertTrue(_opDelete is OpDelete); | ||
} | ||
|
||
[Test] | ||
public function makeRemoveOpDeleteMessage_validInputs_fullCollectionNameCorrect():void | ||
{ | ||
assertEquals(_testFullCollectionName, _opDelete.fullCollectionName); | ||
} | ||
|
||
[Test] | ||
public function makeRemoveOpDeleteMessage_validInputs_selectorReferenceSet():void | ||
{ | ||
assertEquals(_testSelector, _opDelete.selector); | ||
} | ||
} | ||
} |