/// Tests the PointSize Functions
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCasePointSize()
{
    //------Last Checked------//
    // - Dec 6, 2004
    
    const int testValueCount = 5;
    wxInt32 testValues[testValueCount];
    testValues[0] = FontSetting::MIN_POINTSIZE - 1;
    testValues[1] = FontSetting::MIN_POINTSIZE;
    testValues[2] = 12;
    testValues[3] = FontSetting::MAX_POINTSIZE;
    testValues[4] = FontSetting::MAX_POINTSIZE + 1;
    bool expectedResults[testValueCount];
    expectedResults[0] = false;
    expectedResults[1] = true;
    expectedResults[2] = true;
    expectedResults[3] = true;
    expectedResults[4] = false;
    
    int i = 0;
    for (; i < testValueCount; i++)
    {
        TEST(wxString::Format(wxT("IsValidPointSize - %d"), testValues[i]),
            (FontSetting::IsValidPointSize(testValues[i]) == expectedResults[i]));
        
        FontSetting fontSetting;
        TEST(wxString::Format(wxT("SetPointSize - %d"), testValues[i]), 
            (fontSetting.SetPointSize(testValues[i]) == expectedResults[i]) &&
            ((!expectedResults[i]) ? 1 :
                (fontSetting.GetPointSize() == testValues[i]))
        );
    }
        
    return (true);
}
/// Tests the Weight Functions
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseWeight()
{
    //------Last Checked------//
    // - Dec 6, 2004
    
    const int testValueCount = 17;
    wxInt32 testValues[testValueCount];
    testValues[0] = FontSetting::weightDontCare;
    testValues[1] = FontSetting::weightThin;
    testValues[2] = FontSetting::weightExtraLight;
    testValues[3] = FontSetting::weightUltraLight;
    testValues[4] = FontSetting::weightLight;
    testValues[5] = FontSetting::weightNormal;
    testValues[6] = FontSetting::weightRegular;
    testValues[7] = FontSetting::weightMedium;
    testValues[8] = FontSetting::weightSemiBold;
    testValues[9] = FontSetting::weightDemiBold;
    testValues[10] = FontSetting::weightBold;
    testValues[11] = FontSetting::weightExtraBold;
    testValues[12] = FontSetting::weightUltraBold;
    testValues[13] = FontSetting::weightBlack;
    testValues[14] = FontSetting::weightHeavy;
    testValues[15] = -1;
    testValues[16] = 139;
        
    bool expectedResults[testValueCount];
    expectedResults[0] = true;
    expectedResults[1] = true;
    expectedResults[2] = true;
    expectedResults[3] = true;
    expectedResults[4] = true;
    expectedResults[5] = true;
    expectedResults[6] = true;
    expectedResults[7] = true;
    expectedResults[8] = true;
    expectedResults[9] = true;
    expectedResults[10] = true;
    expectedResults[11] = true;
    expectedResults[12] = true;
    expectedResults[13] = true;
    expectedResults[14] = true;
    expectedResults[15] = false;
    expectedResults[16] = false;
    
    int i = 0;
    for (; i < testValueCount; i++)
    {
        TEST(wxString::Format(wxT("IsValidWeight - %d"), testValues[i]),
            (FontSetting::IsValidWeight(testValues[i]) == expectedResults[i]));
        
        FontSetting fontSetting;
        TEST(wxString::Format(wxT("SetWeight - %d"), testValues[i]), 
            (fontSetting.SetWeight(testValues[i]) == expectedResults[i]) &&
            ((!expectedResults[i]) ? 1 :
                (fontSetting.GetWeight() == testValues[i]))
        );
    }

    return (true);
}
/// Tests Serialization
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseSerialize()
{
    //------Last Checked------//
    // - Dec 6, 2004
    bool ok = false;
    
    TestStream testStream;
    PowerTabOutputStream streamOut(testStream.GetOutputStream());
    
    // Write test data to stream
    FontSetting fontSettingOut(wxT("Arial"), 12, FontSetting::weightBold, true,
        true, true, wxColor(255,0,0));
    fontSettingOut.Serialize(streamOut);

    // Output must be OK before using input
    if (testStream.CheckOutputState())
    {
        PowerTabInputStream streamIn(testStream.GetInputStream());
    
        // Read test data back from stream
        FontSetting fontSettingIn;
        fontSettingIn.Deserialize(streamIn,
            PowerTabFileHeader::FILEVERSION_CURRENT);

        // Validate the data
        ok = ((fontSettingIn == fontSettingOut) 
            && (streamIn.CheckState()));
    }
    
    TEST(wxT("Serialize"), ok);
    
    return (true);
}    
/// Tests the Color Functions
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseColor()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    fontSetting.SetColor(wxColor(255,255,255));
    TEST(wxT("SetColor"), (fontSetting.GetColor() == wxColor(255,255,255)));
    return (true);
}
/// Tests the StrikeOut Functions
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseStrikeOut()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    fontSetting.SetStrikeOut();
    TEST(wxT("SetStrikeOut"), (fontSetting.IsStrikeOut()));
    return (true);
}
/// Tests the Underline Functions
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseUnderline()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    fontSetting.SetUnderline();
    TEST(wxT("SetUnderline"), (fontSetting.IsUnderline()));
    return (true);
}
/// Tests the Italic Functions
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseItalic()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    fontSetting.SetItalic();
    TEST(wxT("SetItalic"), (fontSetting.IsItalic()));
    return (true);
}
/// Tests the FaceName Functions
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseFaceName()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    TEST(wxT("SetFaceName - NULL"), (!fontSetting.SetFaceName(NULL)));
    TEST(wxT("SetFaceName - Arial"), ((fontSetting.SetFaceName(wxT("Arial"))) &&
        (fontSetting.GetFaceName() == wxT("Arial"))));
    return (true);
}
// Test Case Functions
/// Tests the Constructors
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseConstructor()
{
    //------Last Checked------//
    // - Dec 6, 2004
    
    // TEST CASE: Default constructor
    {
        FontSetting fontSetting;
        TEST(wxT("Default Constructor"), 
            (fontSetting.GetFaceName() == FontSetting::DEFAULT_FACENAME) &&
            (fontSetting.GetPointSize() == FontSetting::DEFAULT_POINTSIZE) &&
            (fontSetting.GetWeight() == FontSetting::DEFAULT_WEIGHT) &&
            (fontSetting.IsItalic() == FontSetting::DEFAULT_ITALIC) &&
            (fontSetting.IsUnderline() == FontSetting::DEFAULT_UNDERLINE) &&
            (fontSetting.IsStrikeOut() == FontSetting::DEFAULT_STRIKEOUT) &&
            (fontSetting.GetColor() == FontSetting::DEFAULT_COLOR)
        );        
    }
    
    // TEST CASE: Primary constructor
    {
        FontSetting fontSetting(wxT("Arial"), 12, FontSetting::weightBold, true,
            true, true, wxColor(255,0,0));
        TEST(wxT("Primary Constructor"), 
            (fontSetting.GetFaceName() == wxT("Arial")) &&
            (fontSetting.GetPointSize() == 12) &&
            (fontSetting.GetWeight() == FontSetting::weightBold) &&
            (fontSetting.IsItalic()) &&
            (fontSetting.IsUnderline()) &&
            (fontSetting.IsStrikeOut()) &&
            (fontSetting.GetColor() == wxColor(255,0,0))
        );
    }
    
    // TEST CASE: Copy constructor
    {
        FontSetting fontSetting(wxT("Arial"), 12, FontSetting::weightBold, true,
            true, true, wxColor(255,0,0));
        FontSetting fontSetting2(fontSetting);
        TEST(wxT("Copy Constructor"), 
            (fontSetting2.GetFaceName() == wxT("Arial")) &&
            (fontSetting2.GetPointSize() == 12) &&
            (fontSetting2.GetWeight() == FontSetting::weightBold) &&
            (fontSetting2.IsItalic()) &&
            (fontSetting2.IsUnderline()) &&
            (fontSetting2.IsStrikeOut()) &&
            (fontSetting2.GetColor() == wxColor(255,0,0))
        );
    }
    
    return (true);
}
/// Tests the SetFontSettingFromString Function
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseSetFontSettingFromString()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    TEST(wxT("SetFontSettingFromString - NULL string"),
        !fontSetting.SetFontSettingFromString(NULL));
    
    // String format = comma delimited: FaceName,PointSize,Weight,Italic(T/F),
    // Underline(T/F),StrikeOut(T/F),Color
    TEST(wxT("SetFontSettingFromString - valid string"),
        fontSetting.SetFontSettingFromString(wxT("Arial,12,700,T,T,F,255")) && 
        (fontSetting.GetFaceName() == wxT("Arial")) &&
        (fontSetting.GetPointSize() == 12) &&
        (fontSetting.GetWeight() == FontSetting::weightBold) &&
        (fontSetting.IsItalic()) &&
        (fontSetting.IsUnderline()) &&
        (!fontSetting.IsStrikeOut()) &&
        (fontSetting.GetColor() == wxColor(255,0,0))
    );
    
    return (true);
}
/// Deserializes a file from an input stream
/// @param stream Input stream to read from
/// @return True if the document was deserialized, false if not
bool Document::Deserialize(PowerTabInputStream& stream)
{
    // Set the version
    const uint16_t version = m_header.GetVersion();

    m_scoreArray.push_back(new Score("Guitar Score"));
    m_scoreArray.push_back(new Score("Bass Score"));
    m_scoreArray[0]->Deserialize(stream, version);
    m_scoreArray[1]->Deserialize(stream, version);

    // Read the document font settings
    for (size_t fontSettingIndex = 0; fontSettingIndex < NUM_FONT_SETTINGS;
         fontSettingIndex++)
    {
        FontSetting fontSetting;
        fontSetting.Deserialize(stream, version);

        m_fontSettings[fontSettingIndex] = fontSetting;
    }

    // Read the line spacing and fade values
    stream >> m_tablatureStaffLineSpacing >> m_fadeIn >> m_fadeOut;
    return true;
}
/// Tests the SetFontSetting Function
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseSetFontSetting()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    
    TEST(wxT("SetFontSetting - NULL facename"), 
        !fontSetting.SetFontSetting(NULL, 12, FontSetting::weightBold, true,
        true, true, wxColor(255,0,0)));
    TEST(wxT("SetFontSetting - invalid point size"), 
        !fontSetting.SetFontSetting(wxT("Arial"), 0, FontSetting::weightBold,
        true, true, true, wxColor(255,0,0)));
    TEST(wxT("SetFontSetting - invalid weight"), 
        !fontSetting.SetFontSetting(wxT("Arial"), 12, 139, true, true, true,
        wxColor(255,0,0)));
   
    TEST(wxT("SetFontSetting - valid"),
        fontSetting.SetFontSetting(wxT("Arial"), 12, FontSetting::weightBold,
        true, true, true, wxColor(255,0,0)) &&
        (fontSetting.GetFaceName() == wxT("Arial")) &&
        (fontSetting.GetPointSize() == 12) &&
        (fontSetting.GetWeight() == FontSetting::weightBold) &&
        (fontSetting.IsItalic()) &&
        (fontSetting.IsUnderline()) &&
        (fontSetting.IsStrikeOut()) &&
        (fontSetting.GetColor() == wxColor(255,0,0))
    );
    
    return (true);
}