Changed test methods

This commit is contained in:
2022-12-06 22:06:53 -05:00
parent d48d245110
commit b4dc0aed37
31 changed files with 384 additions and 634 deletions

View File

@@ -2,59 +2,49 @@ package com.mattrixwv.project_euler.problems;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;
import com.mattrixwv.project_euler.exceptions.Unsolved;
@ExtendWith(MockitoExtension.class)
public class TestProblem4 extends BaseTest{
@InjectMocks
private Problem4 problem;
static{
description = "Find the largest palindrome made from the product of two 3-digit numbers";
result = "The largest palindrome is 906609";
}
@Test
@Order(1)
@Override
public void testDescription(){
assertEquals("Find the largest palindrome made from the product of two 3-digit numbers", problem.getDescription());
assertFalse(problem.getSolved());
super.testDescription(problem);
}
@Test
@Order(2)
@Override
public void testSolve(){
assertThrows(Unsolved.class, () -> { problem.getPalindromes(); });
assertThrows(Unsolved.class, () -> { problem.getLargestPalindrome(); });
problem.solve();
super.testSolve(problem);
//verify result
assertEquals(1239, problem.getPalindromes().size());
assertEquals(906609, problem.getLargestPalindrome());
assertEquals("The largest palindrome is 906609", problem.getResult());
//verify the problem variables and functions were called
verifyProblem(problem);
//Verify the problem won't be run again
verifyProblemSecondRun(problem);
}
@Test
@Order(3)
@Override
public void testReset(){
problem.reset();
//Verify solved was reset
assertFalse(problem.getSolved());
super.testReset();
//Verify the problem can be solved again
testSolve();
super.testReset(problem);
}
}