TROIKA.ASP - the MVC framework

MockEnvironment.js

Summary

Contains mock implementation of Environment class.

This is part of Troika.ASP Framework - web development MVC framework for ASP 3.0. Please visit www.troika-asp.com for more details.



Version: $Revision: 1.4 $

Author: Pavel Chuchev pav@troika-asp.com


/**
* @fileoverview Contains mock implementation of <tt>Environment</tt> class.
*
* <p>
* This is part of Troika.ASP Framework - web development MVC framework for ASP 3.0.
* Please visit {@link http://www.troika-asp.com www.troika-asp.com} for more details.
* </p>
*
* @author Pavel Chuchev pav@troika-asp.com
* @version $Revision: 1.4 $
*/
/**
* @ignore
*/
var mockRequest = {

};
/**
* @ignore
*/
var mockCookies = {

};
/**
* @ignore
*/
var mockOut = [];
/**
* @ignore
*/
var mockRedirect;
/**
* @ignore
*/
var mockSession = {

};
/**
* @ignore
*/
var mockApplication = {

};

/**
* @ignore
*/
function Environment() {

    this.init();
}
/**
* @ignore
*/
Environment.prototype.init = function () {

    this.request =  new MockRequestAdapter();
    this.response =  new MockResponseAdapter();
    this.session =  new MockSessionAdapter();
    this.server =  new MockServerAdapter();
    this.application =  new MockApplicationAdapter();

    return this;
};
/**
* @ignore
*/
Environment.prototype.reset = function () {

};
//----------------------------------------------------------
/**
* @ignore
*/
function MockRequestAdapter() {

}
/**
* @ignore
*/
MockRequestAdapter.prototype.get = function (key) {

    return mockRequest[key];
};
/**
* @ignore
*/
MockRequestAdapter.prototype.put = function (key, value) {

    mockRequest[key] = value;
};
/**
* @ignore
*/
MockRequestAdapter.prototype.getCookie = function (key) {

    return mockCookies[key];
};
//----------------------------------------------------------
/**
* @ignore
*/
function MockResponseAdapter() {

}
/**
* @ignore
*/
MockResponseAdapter.prototype.redirect = function (path) {

    mockRedirect = path;
};
/**
* @ignore
*/
MockResponseAdapter.prototype.write = function (str) {

    mockOut.push(str);
};
/**
* @ignore
*/
MockResponseAdapter.prototype.addHeader = function (name, value) {

};
/**
* @ignore
*/
MockResponseAdapter.prototype.setCharset = function (value) {

};
/**
* @ignore
*/
MockResponseAdapter.prototype.setContentType = function (value) {

};
/**
* @ignore
*/
MockResponseAdapter.prototype.binaryWrite = function (data) {

};
/**
* @ignore
*/
MockResponseAdapter.prototype.flush = function () {

};
/**
* @ignore
*/
MockResponseAdapter.prototype.setCookie = function (name, value, expires, domain, path) {

    mockCookies[name] = value;
};
//----------------------------------------------------------
/**
* @ignore
*/
function MockSessionAdapter() {

}
/**
* @ignore
*/
MockSessionAdapter.prototype.get = function (key) {

    return mockSession[key];
};
/**
* @ignore
*/
MockSessionAdapter.prototype.put = function (key, value) {

    mockSession[key] = value;
};
/**
* @ignore
*/
MockSessionAdapter.prototype.getId = function () {

    return "12345678";
};
/**
* @ignore
*/
MockSessionAdapter.prototype.addSessionData = function (tag, xml) {

    var value = mockSession._session_data;

    value = value ? value : "";

    value += "<" + tag + ">" + xml + "</" + tag + ">";

    mockSession._session_data = value;
};
/**
* @ignore
*/
MockSessionAdapter.prototype.getSessionData = function () {

    var sessionDataAL = this.get("_session_data");
    if (sessionDataAL) {

        var sessionData = {

        };
        sessionData._xml_ = sessionDataAL.get(0);

        this.remove("_session_data");
        return sessionData;
    }

    return undefined;
};
/**
* @ignore
*/
MockSessionAdapter.prototype.remove = function (key) {

    delete mockSession[key];
};
//----------------------------------------------------------
/**
* @ignore
*/
function MockServerAdapter() {

}
/**
* @ignore
*/
MockServerAdapter.prototype.transfer = function (path) {

};
/**
* @ignore
*/
MockServerAdapter.prototype.mapPath = function (path) {

};
//----------------------------------------------------------
/**
* @ignore
*/
MockApplicationAdapter.APP_ROOT = "root";
/**
* @ignore
*/
function MockApplicationAdapter() {

}
/**
* @ignore
*/
MockApplicationAdapter.prototype.put = function (key, value) {

    if (value) {

        mockApplication[key] = "" + value;
    }
    else {

        this.remove(key);
    }
};
/**
* @ignore
*/
MockApplicationAdapter.prototype.get = function (key) {

    return mockApplication[key];
};
/**
* @ignore
*/
MockApplicationAdapter.prototype.getAppRoot = function () {

    return this.get(MockApplicationAdapter.APP_ROOT);
};
/**
* @ignore
*/
MockApplicationAdapter.prototype.remove = function (key) {

    delete mockApplication[key];
};

TROIKA.ASP - the MVC framework

www.troika-asp.com
Documentation generated on Sun Jun 15 17:59:32 2008