package com.javahonk;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import junit.framework.Assert;

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

import com.javahonk.model.Message;


public class MockitoMessageImpleTestUsingMockMethod {

	private IMockitoMessage iMockitoMessage;

	@Before
	public void setUp() throws Exception {
		iMockitoMessage = mock(IMockitoMessage.class);
	}
	@After
	public void tearoff() {
		iMockitoMessage = null;
	}

	@Test
	public void testGetGreetings() {

		Message morning = new Message();
		morning.setGreeting("Good Morning");

		Message evening = new Message();
		evening.setGreeting("Good Evening");

		when(iMockitoMessage.timeFrame("Morning")).thenReturn(morning);
		when(iMockitoMessage.timeFrame("Evening")).thenReturn(evening);

		Assert.assertEquals("Good Morning",iMockitoMessage.timeFrame("Morning").getGreeting());
		Assert.assertEquals("Good Evening",iMockitoMessage.timeFrame("Evening").getGreeting());

		//Now we could verify if stubbed invocation happened or not
		verify(iMockitoMessage).timeFrame("Morning");		

	}

}
