Esempio n. 1
0
        public ModuleContainerBuilder_Build()
        {
            storage       = IsolatedStorageFile.GetUserStoreForAssembly();
            rootDirectory = Path.GetFullPath(Guid.NewGuid().ToString());

            // Create a fake set of scripts in modules.
            Directory.CreateDirectory(Path.Combine(rootDirectory, "lib"));
            File.WriteAllText(Path.Combine(rootDirectory, "lib", "jquery.js"),
                              "function jQuery(){}");
            File.WriteAllText(Path.Combine(rootDirectory, "lib", "knockout.js"),
                              "function knockout(){}");

            Directory.CreateDirectory(Path.Combine(rootDirectory, "app"));
            File.WriteAllText(Path.Combine(rootDirectory, "app", "widgets.js"),
                              "/// <reference path=\"../lib/jquery.js\"/>\r\n/// <reference path=\"../lib/knockout.js\"/>\r\nfunction widgets(){}");
            File.WriteAllText(Path.Combine(rootDirectory, "app", "main.js"),
                              "/// <reference path=\"widgets.js\"/>\r\nfunction main() {}");

            var svn = new DirectoryInfo(Path.Combine(rootDirectory, ".svn"));

            svn.Create();
            svn.Attributes |= FileAttributes.Hidden;

            Directory.CreateDirectory(Path.Combine(rootDirectory, "nojs"));
            File.WriteAllText(Path.Combine(rootDirectory, "nojs", "foo.txt"), "foo");

            var builder = new ScriptModuleContainerBuilder(storage, rootDirectory, new CoffeeScriptCompiler(File.ReadAllText));

            builder.AddModuleForEachSubdirectoryOf("", "");
            container = builder.Build();
        }
Esempio n. 2
0
        public ModuleContainerBuilder_Build_when_already_cached_in_storage()
        {
            storage       = IsolatedStorageFile.GetUserStoreForAssembly();
            rootDirectory = Path.GetFullPath(Guid.NewGuid().ToString());

            // Create a fake set of scripts in modules.
            Directory.CreateDirectory(Path.Combine(rootDirectory, "junk"));
            File.WriteAllText(Path.Combine(rootDirectory, "junk", "test.js"),
                              "function junk(){}");
            Directory.CreateDirectory(Path.Combine(rootDirectory, "lib"));
            File.WriteAllText(Path.Combine(rootDirectory, "lib", "jquery.js"),
                              "function jQuery(){}");
            Directory.CreateDirectory(Path.Combine(rootDirectory, "app"));
            File.WriteAllText(Path.Combine(rootDirectory, "app", "widgets.js"),
                              "/// <reference path=\"../lib/jquery.js\"/>\r\nfunction widgets(){}");
            File.WriteAllText(Path.Combine(rootDirectory, "app", "main.js"),
                              "/// <reference path=\"widgets.js\"/>\r\nfunction main() {}");

            // Create the "old" continer.
            var builder = new ScriptModuleContainerBuilder(storage, rootDirectory, new CoffeeScriptCompiler(File.ReadAllText));

            builder.AddModule("lib", null);
            builder.AddModule("app", null);
            builder.AddModule("junk", null);
            var oldContainer = builder.Build();

            oldContainer.UpdateStorage("scripts.xml");

            // Now simulate changes to the modules.
            File.WriteAllText(Path.Combine(rootDirectory, "lib", "knockout.js"),
                              "function knockout(){}");
            File.WriteAllText(Path.Combine(rootDirectory, "app", "widgets.js"),
                              "/// <reference path=\"../lib/jquery.js\"/>\r\n/// <reference path=\"../lib/knockout.js\"/>\r\nfunction widgets(){}");
            // Build the updated container to excerise container manifest loading and differencing.
            builder = new ScriptModuleContainerBuilder(storage, rootDirectory, new CoffeeScriptCompiler(File.ReadAllText));
            builder.AddModule("lib", null);
            builder.AddModule("app", null);
            container = builder.Build();
            container.UpdateStorage("scripts.xml");
        }
        public ModuleContainerBuilder_AddModuleForEachSubdirectoryOf()
        {
            storage = IsolatedStorageFile.GetUserStoreForAssembly();
            rootDirectory = Path.GetFullPath(Guid.NewGuid().ToString());

            // Create a fake set of scripts in modules.
            Directory.CreateDirectory(Path.Combine(rootDirectory, "lib"));
            File.WriteAllText(Path.Combine(rootDirectory, "lib", "jquery.js"),
                "function jQuery(){}");
            File.WriteAllText(Path.Combine(rootDirectory, "lib", "knockout.js"),
                "function knockout(){}");

            Directory.CreateDirectory(Path.Combine(rootDirectory, "app"));
            File.WriteAllText(Path.Combine(rootDirectory, "app", "widgets.js"),
                "/// <reference path=\"../lib/jquery.js\"/>\r\n/// <reference path=\"../lib/knockout.js\"/>\r\nfunction widgets(){}");
            File.WriteAllText(Path.Combine(rootDirectory, "app", "main.js"),
                "/// <reference path=\"widgets.js\"/>\r\nfunction main() {}");

            var builder = new ScriptModuleContainerBuilder(storage, rootDirectory, new CoffeeScriptCompiler(File.ReadAllText));
            builder.AddModuleForEachSubdirectoryOf("", "");
            container = builder.Build();
        }
        public ModuleContainerBuilder_Build_when_already_cached_in_storage()
        {
            storage = IsolatedStorageFile.GetUserStoreForAssembly();
            rootDirectory = Path.GetFullPath(Guid.NewGuid().ToString());

            // Create a fake set of scripts in modules.
            Directory.CreateDirectory(Path.Combine(rootDirectory, "junk"));
            File.WriteAllText(Path.Combine(rootDirectory, "junk", "test.js"),
                "function junk(){}");
            Directory.CreateDirectory(Path.Combine(rootDirectory, "lib"));
            File.WriteAllText(Path.Combine(rootDirectory, "lib", "jquery.js"),
                "function jQuery(){}");
            Directory.CreateDirectory(Path.Combine(rootDirectory, "app"));
            File.WriteAllText(Path.Combine(rootDirectory, "app", "widgets.js"),
                "/// <reference path=\"../lib/jquery.js\"/>\r\nfunction widgets(){}");
            File.WriteAllText(Path.Combine(rootDirectory, "app", "main.js"),
                "/// <reference path=\"widgets.js\"/>\r\nfunction main() {}");

            // Create the "old" continer.
            var builder = new ScriptModuleContainerBuilder(storage, rootDirectory, new CoffeeScriptCompiler(File.ReadAllText));
            builder.AddModule("lib", null);
            builder.AddModule("app", null);
            builder.AddModule("junk", null);
            var oldContainer = builder.Build();
            oldContainer.UpdateStorage("scripts.xml");

            // Now simulate changes to the modules.
            File.WriteAllText(Path.Combine(rootDirectory, "lib", "knockout.js"),
                "function knockout(){}");
            File.WriteAllText(Path.Combine(rootDirectory, "app", "widgets.js"),
                "/// <reference path=\"../lib/jquery.js\"/>\r\n/// <reference path=\"../lib/knockout.js\"/>\r\nfunction widgets(){}");
            // Build the updated container to excerise container manifest loading and differencing.
            builder = new ScriptModuleContainerBuilder(storage, rootDirectory, new CoffeeScriptCompiler(File.ReadAllText));
            builder.AddModule("lib", null);
            builder.AddModule("app", null);
            container = builder.Build();
            container.UpdateStorage("scripts.xml");
        }