package com.blocksolid.okrello.display;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

import java.lang.Exception;

public class ScoresTest {
    Scores scores = new Scores();

    // Tests for extractScoreFromString method
    // Positive tests for the 11 possible scores
    @Test
    public void extractScoreFromString_typicalStringEndingIn0point0_returns0point0() throws Exception {
        // A string containing "[0.0]" should return a score of "0.0"
        String string = "This is a typical card title structure [0.0]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.0", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point1_returns0point1() throws Exception {
        // A string containing "[0.1]" should return a score of "0.1"
        String string = "This is a typical card title structure [0.1]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.1", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point2_returns0point2() throws Exception {
        // A string containing "[0.2]" should return a score of "0.2"
        String string = "This is a typical card title structure [0.2]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.2", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point3_returns0point3() throws Exception {
        // A string containing "[0.3]" should return a score of "0.3"
        String string = "This is a typical card title structure [0.3]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.3", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point4_returns0point4() throws Exception {
        // A string containing "[0.4]" should return a score of "0.4"
        String string = "This is a typical card title structure [0.4]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.4", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point5_returns0point5() throws Exception {
        // A string containing "[0.5]" should return a score of "0.5"
        String string = "This is a typical card title structure [0.5]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.5", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point6_returns0point6() throws Exception {
        // A string containing "[0.6]" should return a score of "0.6"
        String string = "This is a typical card title structure [0.6]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.6", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point7_returns0point7() throws Exception {
        // A string containing "[0.7]" should return a score of "0.7"
        String string = "This is a typical card title structure [0.7]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.7", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point8_returns0point8() throws Exception {
        // A string containing "[0.8]" should return a score of "0.8"
        String string = "This is a typical card title structure [0.8]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.8", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn0point9_returns0point9() throws Exception {
        // A string containing "[0.9]" should return a score of "0.9"
        String string = "This is a typical card title structure [0.9]";
        String result = scores.extractScoreFromString(string);
        assertEquals("0.9", result);
    }

    @Test
    public void extractScoreFromString_typicalStringEndingIn1point0_returns1point0() throws Exception {
        // A string containing "[1.0]" should return a score of "1.0"
        String string = "This is a typical card title structure [1.0]";
        String result = scores.extractScoreFromString(string);
        assertEquals("1.0", result);
    }
}
@@ -4281,9 +4281,469 @@
 ;%0A    %7D%0A
+%0A%0A    // Tests for numbers above 1.0 that should be rounded down to 1.0%0A    @Test%0A    public void extractScoreFromString_typicalStringEndingIn1point1_returns1point0() throws Exception %7B%0A        // A string containing %22%5B1.1%5D%22 should return a score of %221.0%22%0A        String string = %22This is a typical card title structure with an invalid score of %5B1.1%5D%22;%0A        String result = scores.extractScoreFromString(string);%0A        assertEquals(%221.0%22, result);%0A    %7D%0A%0A
 %7D

Add failing unit test that check for a returned value of "1.0" if matched string returns above 1.0