var opString;
QUnit.module("CI.String", {
    setup: function() {
        CIString = CI.String;
        ok(CIString !== undefined, "Test Data Created");
    },
    teardown: function() {
        CIString = undefined;
        ok(CIString === undefined, "Test Data Deleted");
    }
});

test("replaceAll", function() {
    var find = "test";
    var replace = "boo";
    var str = "this is a test";
    var result = CIString.replaceAll(find, replace, str);
    ok(result = "this is a boo");
});


test("startsWith", function() {
    var string = "hello";
    var result = CIString.startsWith(string, "h");
    ok(result === true);
});


test("startsWith", function() {
    var string = "hello";
    var result = CIString.startsWith(string, "p");
    ok(result === false);
});


test("killWhiteSpace", function() {
    var string = " hello Test ";
    var result = CIString.killWhiteSpace(string);
    ok(result == "helloTest");
})

test("reduceWhiteSpace", function() {
    var string = "hello  Test";
    var result = CIString.reduceWhiteSpace(string);
    ok(result == "hello Test");
})

test("endsWith", function() {
    var string = "hello";
    var result = CIString.endsWith(string, "o");
    ok(result === true);
})

test("endsWith", function() {
    var string = "hello";
    var result = CIString.endsWith(string, "z");
    ok(result === false);
})

test("trim", function() {
    var string = " hello";
    var result = CIString.trim(string);
    ok(result == "hello");
})

test("trim", function() {
    var string = "hello ";
    var result = CIString.trim(string);
    ok(result == "hello");
})

test("trim", function() {
    var string = " hello ";
    var result = CIString.trim(string);
    ok(result == "hello");
})

test("format", function() {
    var string = "This is a test of the format function";
    var result = CIString.format("This is a test of the {0} function", ["format"]);
    ok(result == string);
})


test("format", function() {
    var string = "This is a test of the format function";
    var result = CIString.format("This is a {1} of the {0} function", ["format", "test"]);
    ok(result == string);
})

var sb;
QUnit.module("CI.StringBuilder", {
    setup: function() {
        sb = new CI.StringBuilder();
        ok(sb !== undefined, "Test Data Created");
    },
    teardown: function() {
        sb = undefined;
        ok(sb === undefined, "Test Data Deleted");
    }
});

test("append", function() {
    //Arrange
    var expected = "string1";
    //Act
    sb.append("string1")
    var result = sb.toString();
    //Assert
    ok(expected == result);
})

test("appendFormat", function() {
    //Arrange
    var expected = "This is a test of the format function";
    //Act
    sb.append("This")
    sb.appendFormat(" is a test of the {0} function", ["format"]);
    var result = sb.toString();
    //Assert
    ok(expected == result);
})

test("appendLine", function() {
    //Arrange
    var expected = "This is a test of the \r\n appendLine function";
    //Act
    sb.appendLine("This is a test of the ");
    sb.append(" appendLine function");

    var result = sb.toString();
    //Assert
    ok(expected == result);
})

test("clear", function() {
    //Arrange
    //Act
    sb.appendLine("This is a test of the ");
    sb.append(" appendLine function");

    var result = sb.clear();
    //Assert
    ok(result === undefined);
})

test("camelize",function(){
    var result = CI.String.camelize("foo-bar");
    ok (result == "fooBar");
});

test("stripTags",function(){
    var string = "<img src='asdsada' alt='aasdsa'/>test";
    var result = CI.String.stripTags(string);
    ok(result == "test");
})

test("getOrdinal",function(){
    var result = CI.String.getOrdinal(1);
    ok (result == "1st");
});

test("getOrdinal",function(){
    var result = CI.String.getOrdinal(2);
    ok (result == "2nd");
});

test("getOrdinal",function(){
    var result = CI.String.getOrdinal(3);
    ok (result == "3rd");
});

test("getOrdinal",function(){
    var result = CI.String.getOrdinal(100);
    ok (result == "100th");
});

test("htmlEscape",function(){
    var string = "<div>this is a test</div>";
    var result = CI.String.htmlEscape(string);
    var expected = "&lt;div&gt;this is a test&lt;/div&gt;"
    ok(result == expected);
});