Exemplo n.º 1
0
        public void ClosureExternsGenerator_Generate_Test()
        {
            var types    = new Type[] { typeof(A) };
            var actual   = ClosureExternsGenerator.Generate(types);
            var expected = @"
/** @const */
var Types = {};

// ClosureExterns.Tests.ClosureExternsGeneratorTest+B
/** @constructor
 */
Types.B = function() {};
/** @type {Array.<number>} */
Types.B.prototype.intArray = null;

// ClosureExterns.Tests.ClosureExternsGeneratorTest+A
/** @constructor
 */
Types.A = function() {};
/** @type {string} */
Types.A.prototype.stringValue = '';
/** @type {number} */
Types.A.prototype.intValue = 0;
/** @type {?number} */
Types.A.prototype.nullableIntValue = null;
/** @type {Types.B} */
Types.A.prototype.b = null;
/** @type {Array.<Types.B>} */
Types.A.prototype.bs = null;
";

            Assert.AreEqual(expected.Trim(), actual.Trim());
        }
Exemplo n.º 2
0
        public void ClosureExternsGenerator_GenerateWithOptions_NamespaceExpression_Test()
        {
            var types       = new Type[] { };
            var testOptions = GetTestOptions();

            testOptions.NamespaceDefinitionExpression = x => String.Format("goog.provide('{0}');", x);
            var actual = ClosureExternsGenerator.Generate(types, testOptions);

            var expected = "goog.provide('TestNamespace');";

            Assert.AreEqual(expected.Trim(), actual.Trim());
        }
Exemplo n.º 3
0
        public void ClosureExternsGenerator_GenerateWithOptions_MapType_Test()
        {
            var types       = new Type[] { typeof(AClass) };
            var testOptions = GetTestOptions();

            testOptions.MapType = x => typeof(Boolean);
            var actual = ClosureExternsGenerator.Generate(types, testOptions);

            var expected = @"
/** @const */
var TestNamespace = {};";

            Assert.AreEqual(expected.Trim(), actual.Trim());
        }
Exemplo n.º 4
0
        public void ClosureExternsGenerator_GenerateWithOptions_Test()
        {
            var types       = new Type[] { typeof(AClass) };
            var testOptions = GetTestOptions();
            var actual      = ClosureExternsGenerator.Generate(types, testOptions);

            var expected = @"
/** @const */
var TestNamespace = {};

// ClosureExterns.Tests.ClosureExternsGeneratorTest+BClass
/** @constructor
 * @something TestNamespace.Bee
 */
TestNamespace.Bee = function TestNamespace.Bee() { };
/** @type {Array.<number>} */
TestNamespace.Bee.prototype.intArray = null;

// ClosureExterns.Tests.ClosureExternsGeneratorTest+CClass
/** @constructor
 * @something TestNamespace.C
 */
TestNamespace.C = function TestNamespace.C() { };
/** @type {?number} */
TestNamespace.C.prototype.nullableInt = null;

// ClosureExterns.Tests.ClosureExternsGeneratorTest+AClass
/** @constructor
 * @something TestNamespace.A
 */
TestNamespace.A = function TestNamespace.A() { };
/** @type {string} */
TestNamespace.A.prototype.stringValue = '';
/** @type {number} */
TestNamespace.A.prototype.intValue = 0;
/** @type {TestNamespace.Bee} */
TestNamespace.A.prototype.b = null;
/** @type {Array.<TestNamespace.Bee>} */
TestNamespace.A.prototype.bs = null;
/** @type {TestNamespace.C} */
TestNamespace.A.prototype.c = null;
";

            Assert.AreEqual(expected.Trim(), actual.Trim());
        }
Exemplo n.º 5
0
        public void ClosureExternsGenerator_DictClass_Test()
        {
            var types    = new Type[] { typeof(DictClass) };
            var actual   = ClosureExternsGenerator.Generate(types);
            var expected = @"
/** @const */
var Types = {};

// ClosureExterns.Tests.ClosureExternsGeneratorTest+DictClass
/** @constructor
 */
Types.DictClass = function() {};
/** @type {Object.<string, number>} */
Types.DictClass.prototype.dictProperty = null;
";

            Assert.AreEqual(expected.Trim(), actual.Trim());
        }