Пример #1
0
        public void TestKoInheritance()
        {
            var kogen = new KnockoutReflectionGenerator();

            kogen.GenerateFromType(typeof(Test3));
            var o = new OutputGenerator();

            o.GenerateModuleContent(kogen.Module, null);
            Assert.AreEqual(null, Helper.StringCompare(@"
class test3A implements IObservableITest3A {
    prop1 = ko.observable<number>();
}
class test3 extends test3A implements IObservableITest3B, IObservableITest3C {
    prop2 = ko.observable<string>();
    prop3 = ko.observable<string>();
    prop4 = ko.observable<IObservableITest3A>();
    propOwn = ko.observable<test3A>();
}
interface IObservableITest3A {
    prop1: KnockoutObservable<number>;
}
interface IObservableITest3B extends IObservableITest3A {
    prop2: KnockoutObservable<string>;
}
interface IObservableITest3C extends IObservableITest3A, IObservableITest3B {
    prop3: KnockoutObservable<string>;
    prop4: KnockoutObservable<IObservableITest3A>;
}
", o.Output));
        }
Пример #2
0
        public void TestKoReflection()
        {
            var kogen = new KnockoutReflectionGenerator();

            kogen.GenerateFromType(typeof(Test1B));
            var o = new OutputGenerator();

            o.GenerateModuleContent(kogen.Module, null);
            Assert.AreEqual(null, Helper.StringCompare(@"
class test1 {
    Prop1 = ko.observable<string>();
    Prop2 = ko.observable<number>();
}
class test1B extends test1 {
    Prop3 = ko.observable<boolean>();
    Ref = ko.observable<test1>();
    PropArray = ko.observableArray<string>();
    SelfArray = ko.observableArray<test1B>();
}", o.Output));
        }