package com.github.kohanyirobert.ebson;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public final class BsonDocumentTest {

  private static final String STRING_KEY = "string-key";
  private static final String NULL_KEY = "null-key";
  private static final String MISSING_KEY = "string-key-not-present";

  private static final Object STRING_VALUE = "string-value";

  private final BsonDocument document;

  public BsonDocumentTest() {
    document = BsonDocuments.of(
        STRING_KEY, STRING_VALUE,
        NULL_KEY, null);
  }

  @Test
  public void containsKey_withStringKey() {
    assertTrue(document.containsKey(STRING_KEY));
  }

  @Test(expected = ClassCastException.class)
  public void containsKey_withNotStringKey() {
    document.containsKey(new Object());
  }

  @Test
  public void get_keyPresent_withStringKey() {
    assertEquals(STRING_VALUE, document.get(STRING_KEY));
  }

  @Test(expected = IllegalArgumentException.class)
  public void get_keyNotPresent_withStringKey() {
    document.get(MISSING_KEY);
  }

  @Test(expected = ClassCastException.class)
  public void get_keyPresent_withNotStringKey() {
    document.get(new Object());
  }
}

@@ -239,24 +239,81 @@
 tring-key%22;%0A
+  private static final String BINARY_KEY = %22binary-key%22;%0A
   private st
@@ -489,46 +489,213 @@
 e%22;%0A
-%0A  private final BsonDocument document
+  private static final Object BINARY_VALUE1 = new byte%5B%5D %7B42%7D;%0A  private static final Object BINARY_VALUE2 = new byte%5B%5D %7B42%7D;%0A%0A  private final BsonDocument document1;%0A  private final BsonDocument document2
 ;%0A%0A 
@@ -735,16 +735,17 @@
 document
+1
  = BsonD
@@ -791,16 +791,180 @@
 _VALUE,%0A
+        BINARY_KEY, BINARY_VALUE1,%0A        NULL_KEY, null);%0A%0A    document2 = BsonDocuments.of(%0A        STRING_KEY, STRING_VALUE,%0A        BINARY_KEY, BINARY_VALUE2,%0A
         
@@ -1052,32 +1052,33 @@
 ertTrue(document
+1
 .containsKey(STR
@@ -1197,16 +1197,17 @@
 document
+1
 .contain
@@ -1321,24 +1321,25 @@
 UE, document
+1
 .get(STRING_
@@ -1459,24 +1459,25 @@
     document
+1
 .get(MISSING
@@ -1595,16 +1595,17 @@
 document
+1
 .get(new
@@ -1619,11 +1619,122 @@
 ());%0A  %7D
+%0A%0A  @Test%0A  public void equal_twoDocumentsWithSameLogicalValues() %7B%0A    assertEquals(document1, document2);%0A  %7D
 %0A%7D%0A

Update BsonDocumentTest