/** @overview nodeunit test case. */

var fs = require('fs'),
    testResource = require('../../../test_resource'),
    FileLogger = require('../../../../lib/log/file_logger.js');

exports.setUp = function (done) {
    done();
};

exports.tearDown = function (done) {
    done();
};

exports['Get level as string.'] = function (test) {
    test.equal(FileLogger._levelString(1), 'FATAL');
    test.equal(FileLogger._levelString(2), 'ERROR');
    test.equal(FileLogger._levelString(3), 'WARN');
    test.equal(FileLogger._levelString(4), 'INFO');
    test.equal(FileLogger._levelString(5), 'DEBUG');
    test.equal(FileLogger._levelString(6), 'TRACE');
    test.done();
};
exports['Write a file log.'] = function (test) {
    var filename = testResource.resolveWorkFile('work-file-log.log');
    var logger = new FileLogger('DEBUG').filename(filename).console(false);
    logger.info('foo');
    logger.info('bar');
    fs.readFile(filename, function (err, content) {
        test.ifError(err);
        test.ok(content.toString());
        logger.kill();
        test.done();
    });
};