/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.pedrovgs.app.problem3;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @author Pedro Vicente Gómez Sánchez.
 */
public class SumBinaryNumberTest {

  private SumBinaryNumbers sumBinaryNumbers;

  @Before public void setUp() {
    this.sumBinaryNumbers = new SumBinaryNumbers();
  }

  @Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullInputs() {
    sumBinaryNumbers.sumBinaryNumbersCheating(null, null);
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldNotAcceptMalformedBinaryNumbers() {
    String n1 = "10";
    String n2 = "2";

    sumBinaryNumbers.sumBinaryNumbersCheating(n1, n2);
  }

  @Test public void zeroPlusZeroEqualsZero() {
    String n1 = "0";
    String n2 = "0";

    String result = sumBinaryNumbers.sumBinaryNumbersCheating(n1, n2);

    assertEquals("0", result);
  }

  @Test public void zeroPlusTwoEqualsTwo() {
    String n1 = "0";
    String n2 = "10";

    String result = sumBinaryNumbers.sumBinaryNumbersCheating(n1, n2);

    assertEquals("10", result);
  }

  @Test public void fivePlusSevenEqualsTwelve() {
    String n1 = "101";
    String n2 = "111";

    String result = sumBinaryNumbers.sumBinaryNumbersCheating(n1, n2);

    assertEquals("1100", result);
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldNotAcceptNullInputsBasedOnPowersOfTwo() {
    sumBinaryNumbers.sumBinaryNumbersBasedOnPowersOfTwo(null, null);
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldNotAcceptMalformedBinaryNumbersBasedOnPowersOfTwo() {
    String n1 = "10";
    String n2 = "2";

    sumBinaryNumbers.sumBinaryNumbersBasedOnPowersOfTwo(n1, n2);
  }

  @Test public void zeroPlusZeroEqualsZeroBasedOnPowersOfTwo() {
    String n1 = "0";
    String n2 = "0";

    String result = sumBinaryNumbers.sumBinaryNumbersBasedOnPowersOfTwo(n1, n2);

    assertEquals("0", result);
  }

  @Test public void zeroPlusTwoEqualsTwoBasedOnPowersOfTwo() {
    String n1 = "00";
    String n2 = "10";

    String result = sumBinaryNumbers.sumBinaryNumbersBasedOnPowersOfTwo(n1, n2);

    assertEquals("10", result);
  }

  @Test public void fivePlusSevenEqualsTwelveBasedOnPowersOfTwo() {
    String n1 = "101";
    String n2 = "111";

    String result = sumBinaryNumbers.sumBinaryNumbersBasedOnPowersOfTwo(n1, n2);

    assertEquals("1100", result);
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldNotAcceptNullInputsBasedOnCount() {
    sumBinaryNumbers.sumBinaryNumbersBasedOnCount(null, null);
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldNotAcceptMalformedBinaryNumbersBasedOnCount() {
    String n1 = "10";
    String n2 = "2";

    sumBinaryNumbers.sumBinaryNumbersBasedOnCount(n1, n2);
  }

  @Test public void zeroPlusZeroEqualsZeroBasedOnCount() {
    String n1 = "0";
    String n2 = "0";

    String result = sumBinaryNumbers.sumBinaryNumbersBasedOnCount(n1, n2);

    assertEquals(Integer.parseInt("0", 2), Integer.parseInt(result, 2));
  }

  @Test public void zeroPlusTwoEqualsTwoBasedOnCount() {
    String n1 = "00";
    String n2 = "10";

    String result = sumBinaryNumbers.sumBinaryNumbersBasedOnCount(n1, n2);

    assertEquals(Integer.parseInt("10", 2), Integer.parseInt(result, 2));
  }

  @Test public void fivePlusSevenEqualsTwelveBasedOnCount() {
    String n1 = "101";
    String n2 = "111";

    String result = sumBinaryNumbers.sumBinaryNumbersBasedOnCount(n1, n2);

    assertEquals(Integer.parseInt("1100", 2), Integer.parseInt(result, 2));
  }
}

@@ -1520,32 +1520,230 @@
 , result);%0A  %7D%0A%0A
+  @Test public void onePlusOneEqualsTwo() %7B%0A    String n1 = %2201%22;%0A    String n2 = %2201%22;%0A%0A    String result = sumBinaryNumbers.sumBinaryNumbersCheating(n1, n2);%0A%0A    assertEquals(%2210%22, result);%0A  %7D%0A%0A
   @Test public v
@@ -1763,32 +1763,32 @@
 woEqualsTwo() %7B%0A
-
     String n1 = 
@@ -2776,32 +2776,258 @@
 , result);%0A  %7D%0A%0A
+  @Test public void onePlusOneEqualsTwoBasedOnPowersOfTwo() %7B%0A    String n1 = %2201%22;%0A    String n2 = %2201%22;%0A%0A    String result = sumBinaryNumbers.sumBinaryNumbersBasedOnPowersOfTwo(n1, n2);%0A%0A    assertEquals(%2210%22, result);%0A  %7D%0A%0A
   @Test public v
@@ -4045,32 +4045,32 @@
 Count(n1, n2);%0A%0A
-
     assertEquals
@@ -4123,32 +4123,247 @@
 sult, 2));%0A  %7D%0A%0A
+  @Test public void onePlusOneEqualsTwoBasedOnCount() %7B%0A    String n1 = %2201%22;%0A    String n2 = %2201%22;%0A%0A    String result = sumBinaryNumbers.sumBinaryNumbersBasedOnCount(n1, n2);%0A%0A    assertEquals(%22010%22, result);%0A  %7D%0A%0A
   @Test public v

Improve coverage for problem 3