Permalink
Browse files

Tests/demos of all additivity of DBObject and Tuple

  • Loading branch information...
1 parent 8c17094 commit b5e91f6fb54fa3aada553a8f5dc35767227f2e33 @bwmcadams bwmcadams committed Dec 8, 2010
Showing with 28 additions and 0 deletions.
  1. +28 −0 casbah-commons/src/test/scala/MongoDBObjectSpec.scala
@@ -153,6 +153,34 @@ class MongoDBObjectSpec extends Specification with PendingUntilFixed {
newObj must beEqualTo(MongoDBObject("x" -> "y", "a" -> "b", "foo" -> "bar", "n" -> 5))
}
+ "Merging a single tuple via += " in {
+ val dbObj = MongoDBObject("x" -> "y", "a" -> "b")
+ dbObj must notBeNull
+ dbObj must haveSuperClass[DBObject]
+ dbObj must beEqualTo(MongoDBObject("x" -> "y", "a" -> "b"))
+
+ dbObj += ("foo" -> "bar")
+
+ dbObj must notBeNull
+ dbObj must haveSuperClass[DBObject]
+
+ dbObj must beEqualTo(MongoDBObject("x" -> "y", "a" -> "b", "foo" -> "bar"))
+
+ }
+ "Merging a set of tuples via ++= " in {
+ val dbObj = MongoDBObject("x" -> "y", "a" -> "b")
+ dbObj must notBeNull
+ dbObj must haveSuperClass[DBObject]
+ dbObj must beEqualTo(MongoDBObject("x" -> "y", "a" -> "b"))
+
+ dbObj += ("foo" -> "bar", "n" -> 5.asInstanceOf[AnyRef], "fbc" -> 542542.2.asInstanceOf[AnyRef])
+
+ dbObj must notBeNull
+ dbObj must haveSuperClass[DBObject]
+
+ dbObj must beEqualTo(MongoDBObject("x" -> "y", "a" -> "b", "foo" -> "bar", "n" -> 5, "fbc" -> 542542.2))
+
+ }
}
}

0 comments on commit b5e91f6

Please sign in to comment.