Пример #1
0
        public void Create_Application()
        {
            var f   = new SenchaFile("Ext.application({ name: 'App' })");
            var app = f.Classes.Single();

            Assert.AreEqual("App", app.ApplicationName);
        }
Пример #2
0
        public void Define_Single_Class()
        {
            var f = new SenchaFile("Ext.define('App.Class1')");

            var classesCount = f.Classes.Count();

            Assert.AreEqual(1, classesCount, "Classes count");

            var className = f.Classes.Single().ClassName;

            Assert.AreEqual("App.Class1", className);
        }
Пример #3
0
        public void Extend_Class()
        {
            var file          = new SenchaFile(@"
Ext.define('App.SubClass', {
    extend: 'App.Class'
});
");
            var cls           = file.Classes.Single();
            var baseClassName = cls.DependencyClassNames.First();

            Assert.AreEqual("App.Class", baseClassName, "Base class name");
        }
Пример #4
0
        public void Application_With_AutoCreateViewport_Undefined()
        {
            var f   = new SenchaFile(@"
Ext.application({ 
    name: 'App'
})
");
            var app = f.Classes.Single();

            Assert.IsNull(app.AutoCreateViewport, "autoCreateViewport value");

            var dependenciesCount = app.DependencyClassNames.Count();

            Assert.AreEqual(0, dependenciesCount, "Dependencies count");
        }
Пример #5
0
        public void Application_With_AutoCreateViewport_Name()
        {
            var f   = new SenchaFile(@"
Ext.application({ 
    name: 'App',
    autoCreateViewport: 'App.view.MyViewport'
})
");
            var app = f.Classes.Single();

            Assert.AreEqual("App.view.MyViewport", app.AutoCreateViewport, "autoCreateViewport value");

            var viewportFullName = app.DependencyClassNames.Single();

            Assert.AreEqual("App.view.MyViewport", viewportFullName, "Dependency's viewport class name");
        }
Пример #6
0
        public void Define_Multiple_Classes()
        {
            var f = new SenchaFile(
                "Ext.define('App.Class1')" + Environment.NewLine +
                "Ext.define('App.Class2')"
                );

            var classesCount = f.Classes.Count();

            Assert.AreEqual(2, classesCount, "Classes count");

            var firstClassName  = f.Classes.First().ClassName;
            var secondClassName = f.Classes.Skip(1).First().ClassName;

            Assert.AreEqual("App.Class1", firstClassName);
            Assert.AreEqual("App.Class2", secondClassName);
        }
Пример #7
0
        public void Define_Store_With_A_Model_Short()
        {
            var file = new SenchaFile(@"
Ext.define('App.store.MyStore', {
    model: 'MyModel'
});
");
            var cls  = file.Classes.Single();
            var mixinDependencies = cls.DependencyClassNames;
            var areSame           = !mixinDependencies
                                    .Except(new[]
            {
                "MyModel"
            })
                                    .Any();

            Assert.IsTrue(areSame, "Dependencies are same");
        }
Пример #8
0
        public void Get_Dependencies()
        {
            var appFile        = new SenchaFile(@"
Ext.application({
    name: 'App',
    controllers: [
        'App.controller.Main'
    ]
})
");
            var controllerFile = new SenchaFile(@"
Ext.define('App.controller.Main', {
    extend: 'Ext.app.Controller',
    views: [
        'App.view.UserForm'
    ]
})
");

            var viewFile = new SenchaFile(@"
Ext.define('App.view.UserForm', {
    extend: 'Ext.form.FormPanel'
})
");

            var files = new[]
            {
                appFile,
                controllerFile,
                viewFile
            };

            appFile.FillDependencies(files);
            controllerFile.FillDependencies(files);
            viewFile.FillDependencies(files);

            Assert.AreEqual(controllerFile, appFile.Dependencies.Single());
            Assert.AreEqual(viewFile, controllerFile.Dependencies.Single());
            Assert.IsFalse(viewFile.Dependencies.Any());
        }
Пример #9
0
        public void Order_Files()
        {
            var appFile        = new SenchaFile(@"
Ext.application({
    name: 'App',
    controllers: [
        'App.controller.Main'
    ]
})
");
            var controllerFile = new SenchaFile(@"
Ext.define('App.controller.Main', {
    extend: 'Ext.app.Controller',
    views: [
        'App.view.UserForm'
    ]
})
");

            var viewFile = new SenchaFile(@"
Ext.define('App.view.UserForm', {
    extend: 'Ext.form.FormPanel'
})
");

            var files = new[]
            {
                appFile,
                controllerFile,
                viewFile
            };

            var orderer      = new SenchaOrderer();
            var orderedFiles = orderer.OrderFiles(files);

            Assert.AreEqual(viewFile, orderedFiles.Skip(0).First(), "viewFile");
            Assert.AreEqual(controllerFile, orderedFiles.Skip(1).First(), "controllerFile");
            Assert.AreEqual(appFile, orderedFiles.Skip(2).First(), "appFile");
        }
Пример #10
0
        public void Define_Controller_With_Stores()
        {
            var file = new SenchaFile(@"
Ext.define('App.controller.Controller', {
    stores: [
        'App.store.Store1',
        'Store2'
    ]
});
");
            var cls  = file.Classes.Single();
            var mixinDependencies = cls.DependencyClassNames;
            var areSame           = !mixinDependencies
                                    .Except(new[]
            {
                "App.store.Store1",
                "App.store.Store2"
            })
                                    .Any();

            Assert.IsTrue(areSame, "Dependencies are same");
        }
Пример #11
0
        public void Add_Required_Class_Names()
        {
            var file = new SenchaFile(@"
Ext.define('App.Class', {
    requires: [
        'App.Class2', 
        'App.Class3'
    ]
});
");
            var cls  = file.Classes.Single();
            var mixinDependencies = cls.DependencyClassNames;
            var areSame           = !mixinDependencies
                                    .Except(new[]
            {
                "App.Class2",
                "App.Class3"
            })
                                    .Any();

            Assert.IsTrue(areSame, "Dependencies are same");
        }
Пример #12
0
        public void Add_Mixins_As_Object()
        {
            var file = new SenchaFile(@"
Ext.define('App.Class', {
    mixins: {
        observable: 'Ext.mixin.Observable', 
        responsive: 'Ext.mixin.Responsive'
    }
});
");
            var cls  = file.Classes.Single();
            var mixinDependencies = cls.DependencyClassNames;
            var areSame           = !mixinDependencies
                                    .Except(new[]
            {
                "Ext.mixin.Observable",
                "Ext.mixin.Responsive"
            })
                                    .Any();

            Assert.IsTrue(areSame, "Dependencies are same");
        }
Пример #13
0
        public void Define_Application_With_Controllers()
        {
            var file = new SenchaFile(@"
Ext.application({
    name: 'App',
    controllers: [
        'App.controller.Controller1',
        'Controller2'
    ]
});
");
            var cls  = file.Classes.Single();
            var mixinDependencies = cls.DependencyClassNames;
            var areSame           = !mixinDependencies
                                    .Except(new[]
            {
                "App.controller.Controller1",
                "App.controller.Controller2"
            })
                                    .Any();

            Assert.IsTrue(areSame, "Dependencies are same");
        }