package com.example.springip;

import com.example.springip.lab2.service.OperationService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class SpringipApplicationTests {
	@Autowired
	OperationService operationService;

	@Test
	public void testSumString() {
		final String res = (String) operationService.sum("Привет ", "Мир!", "str");
		Assertions.assertEquals("Привет Мир!", res);
	}

	@Test
	public void testSumNum() {
		final Integer res = (Integer) operationService.sum(1, 2, "num");
		Assertions.assertEquals(3, res);
	}

	@Test
	public void testMulString() {
		final String res = (String) operationService.mul("A", 4, "str");
		Assertions.assertEquals("AAAA", res);
	}

	@Test
	public void testMulNum() {
		final Integer res = (Integer) operationService.mul(2, 4, "num");
		Assertions.assertEquals(8, res);
	}

	@Test
	public void testLengthString() {
		final Integer res = (Integer) operationService.length("Hello", "str");
		Assertions.assertEquals(5, res);
	}

	@Test
	public void testLengthNum() {
		final Integer res = (Integer) operationService.length(777,"num");
		Assertions.assertEquals(3, res);
	}
	@Test
	public void testStWString() {
		final boolean res = (boolean) operationService.startsWith("Orange","Or", "str");
		Assertions.assertEquals(true, res);
	}

	@Test
	public void testStWNum() {
		final boolean res = (boolean) operationService.startsWith(777, 77, "num");
		Assertions.assertEquals(true, res);
	}

}
