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,31 +2,33 @@ 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 TestProblem6 extends BaseTest{
@InjectMocks
private Problem6 problem;
static{
description = "Find the difference between the sum of the squares and the square of the sum of the numbers 1-100.";
result = "The difference between the sum of the squares and the square of the sum of all numbers from 1-100 is 25164150";
}
@Test
@Order(1)
@Override
public void testDescription(){
assertEquals("Find the difference between the sum of the squares and the square of the sum of the numbers 1-100.", problem.getDescription());
assertFalse(problem.getSolved());
super.testDescription(problem);
}
@Test
@Order(2)
@Override
public void testSolve(){
assertThrows(Unsolved.class, () -> { problem.getSumOfSquares(); });
@@ -39,24 +41,12 @@ public class TestProblem6 extends BaseTest{
assertEquals(338350, problem.getSumOfSquares());
assertEquals(25502500, problem.getSquareOfSum());
assertEquals(25164150, problem.getDifference());
assertEquals("The difference between the sum of the squares and the square of the sum of all numbers from 1-100 is 25164150", 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);
}
}