package debugger;

import org.junit.jupiter.api.Test;

import static debugger.Debugger.expect;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
 * Created by HiekmaHe on 05.05.2017.
 */
public class OtherwiseDebuggerTest
{
	@Test
	public void testMurmur() {
		assertThrows(
				AssertionFailedError.class, () ->
						expect(false).toBeTrue().otherwiseMurmur());
	}

	@Test
	public void testMurmurExpectMessageToBeEmpty() {
		// arrange // act
		String message = expect(true).toBeTrue().otherwiseMurmur();

		// assert
		expect(message).toBeEmpty().otherwiseComplain();
	}

	@Test
	public void testMurmurExpectMessageToBeNotEmpty() {
		// arrange // act
		AssertionFailedError assertionFailedError = null;
		try {
			expect(false).toBeTrue().otherwiseMurmur();
		} catch ( AssertionFailedError e) {
			assertionFailedError = e;
		}

		// assert
		expect(assertionFailedError).toBeNotNull().otherwiseComplain();
		expect(assertionFailedError.getMessage()).toBeNotEmpty().otherwiseComplain();
		expect(assertionFailedError.getMessage()).toBeEqualTo("assertion error.").otherwiseComplain();
	}

	@Test
	public void testComplain() {
		assertThrows(
				AssertionFailedError.class, () ->
						expect(false).toBeTrue().otherwiseComplain());
	}

	@Test
	public void testComplainExpectMessageToBeEmpty() {
		// arrange // act
		String message = expect(true).toBeTrue().otherwiseComplain();

		// assert
		expect(message).toBeEmpty().otherwiseComplain();
	}

	@Test
	public void testComplainExpectMessageToBeNotEmpty() {
		// arrange // act
		AssertionFailedError assertionFailedError = null;
		try {
			expect(false).toBeTrue().otherwiseComplain();
		} catch (AssertionFailedError e) {
			assertionFailedError = e;
		}

		// assert
		expect(assertionFailedError).toBeNotNull().otherwiseComplain();
		expect(assertionFailedError.getMessage()).toBeNotEmpty().otherwiseComplain();
		expect(assertionFailedError.getMessage().hashCode()).toBeEqualTo(-882627246).otherwiseComplain();
	}

	@Test
	public void testAnnounce() {
		assertThrows(
				AssertionFailedError.class, () ->
						expect(false).toBeTrue().otherwiseAnnounce("hello"));
	}

	@Test
	public void testAnnounceExpectMessageToBeEmpty() {
		// arrange // act
		String message = expect(true).toBeTrue().otherwiseAnnounce("huh");

		// assert
		expect(message).toBeEmpty().otherwiseComplain();
	}

	@Test
	public void testAnnounceExpectMessageToBeNotEmpty() {
		// arrange // act
		String message = "";
		AssertionFailedError assertionFailedError = null;
		try {
			message = expect(false).toBeTrue().otherwiseAnnounce("ignore me");
		} catch ( AssertionFailedError e) {
			assertionFailedError = e;
		}

		// assert
		expect(assertionFailedError).toBeNotNull().otherwiseComplain();
		expect(assertionFailedError.getMessage()).toBeNotEmpty().otherwiseComplain();
		expect(assertionFailedError.getMessage().hashCode()).toBeEqualTo(443997862).otherwiseComplain();
	}
}
@@ -196,23 +196,16 @@
 17.%0A */%0A
-public 
 class Ot
@@ -226,39 +226,32 @@
 rTest%0A%7B%0A%09@Test%0A%09
-public 
 void testMurmur(
@@ -363,39 +363,32 @@
 ));%0A%09%7D%0A%0A%09@Test%0A%09
-public 
 void testMurmurE
@@ -563,39 +563,32 @@
 ();%0A%09%7D%0A%0A%09@Test%0A%09
-public 
 void testMurmurE
@@ -897,88 +897,8 @@
 ();%0A
-%09%09expect(assertionFailedError.getMessage()).toBeNotEmpty().otherwiseComplain();%0A
 %09%09ex
@@ -994,39 +994,32 @@
 ();%0A%09%7D%0A%0A%09@Test%0A%09
-public 
 void testComplai
@@ -1135,39 +1135,32 @@
 ));%0A%09%7D%0A%0A%09@Test%0A%09
-public 
 void testComplai
@@ -1339,39 +1339,32 @@
 ();%0A%09%7D%0A%0A%09@Test%0A%09
-public 
 void testComplai
@@ -1676,88 +1676,8 @@
 ();%0A
-%09%09expect(assertionFailedError.getMessage()).toBeNotEmpty().otherwiseComplain();%0A
 %09%09ex
@@ -1776,39 +1776,32 @@
 ();%0A%09%7D%0A%0A%09@Test%0A%09
-public 
 void testAnnounc
@@ -1924,39 +1924,32 @@
 ));%0A%09%7D%0A%0A%09@Test%0A%09
-public 
 void testAnnounc
@@ -2145,15 +2145,8 @@
 st%0A%09
-public 
 void
@@ -2212,31 +2212,8 @@
 act%0A
-%09%09String message = %22%22;%0A
 %09%09As
@@ -2271,26 +2271,16 @@
 ry %7B%0A%09%09%09
-message = 
 expect(f
@@ -2524,122 +2524,354 @@
 ge()
-).toBeNotEmpty().otherwiseComplain();%0A%09%09expect(assertionFailedError.getMessage().hashCode()).toBeEqualTo(443997862
+.hashCode()).toBeEqualTo(443997862).otherwiseComplain();%0A%09%7D%0A%09%0A%09@Test%0A%09void testOtherwiseReturnErrorExpectError() %7B%0A%09%09// arrange // act%0A%09%09AssertionFailedError error;%0A%09%09error = expect(false).toBeTrue().otherwiseReturnError();%0A%09%09// assert%0A%09%09expect(error).toBeNotNull().otherwiseComplain();%0A%09%09expect(error.getMessage()).toBeEqualTo(%22assertion error.%22
 ).ot

add otherwiseReturnError Test and refactoring