Example #1
0
        private static DownloadWebresourceConfigTask GetWebresourceTestTask(ConfigFile config, WebResource existingWebresource)
        {
            // Arrange
            OrganizationServiceContext ctx = A.Fake <OrganizationServiceContext>();

            A.CallTo(() => ServiceLocator.Queries.GetWebresources(ctx))
            .ReturnsLazily(() =>
            {
                return(new List <WebResource>
                {
                    existingWebresource
                });
            });

            var configFactoryInstance = A.Fake <IConfigFileService>();

            ServiceLocator.ServiceProvider.RemoveService(typeof(IConfigFileService));
            ServiceLocator.ServiceProvider.AddService(typeof(IConfigFileService), configFactoryInstance);

            A.CallTo(() => configFactoryInstance.FindConfig(A <string> .Ignored, A <bool> .Ignored))
            .WithAnyArguments()
            .Returns(new List <ConfigFile>
            {
                config
            });


            var directoryService = A.Fake <IDirectoryService>();

            ServiceLocator.ServiceProvider.RemoveService(typeof(IDirectoryService));
            ServiceLocator.ServiceProvider.AddService(typeof(IDirectoryService), directoryService);
            A.CallTo(() => directoryService.Search(A <string> .Ignored, A <string> .Ignored))
            .WithAnyArguments()
            .Returns(
                new List <string>()
            {
                @"C:\code\solution\webresources\new_\js\somefile.js"
            }
                );

            var trace = new TraceLogger();

            var task = new DownloadWebresourceConfigTask(ctx, trace);

            task.Prefix = "new";

            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                    @"..\..\..\SparkleXrm.Tasks.Tests\Resources");

            // Act
            task.Execute(path);
            return(task);
        }
Example #2
0
        public void DownloadWebresourceConfig()
        {
            CrmServiceClient crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["integration_testing"].ConnectionString);
            var userId = crmSvc.GetMyCrmUserId();
            var trace  = new TraceLogger();
            var task   = new DownloadWebresourceConfigTask(crmSvc, trace);

            task.Prefix = "new_";
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                    @"..\..\..");

            task.Execute(path);
        }
Example #3
0
        private static DownloadWebresourceConfigTask GetWebresourceTestTask(ConfigFile config, WebResource existingWebresource)
        {
            using (ShimsContext.Create())
            {
                // Arrange
                Fakes.ShimQueries.GetWebresourcesOrganizationServiceContext = (OrganizationServiceContext context) =>
                {
                    return(new List <WebResource>
                    {
                        existingWebresource
                    });
                };

                SparkleXrm.Tasks.Config.Fakes.ShimConfigFile.FindConfigStringBoolean = (string folder, bool raiseEror) =>
                {
                    return(new List <ConfigFile>
                    {
                        config
                    });
                };

                SparkleXrm.Tasks.Fakes.ShimDirectoryEx.SearchStringStringListOfString = (string folder, string search, List <string> paths) =>
                {
                    return(new List <string>()
                    {
                        @"C:\code\solution\webresources\new_\js\somefile.js"
                    });
                };

                SparkleXrm.Tasks.Config.Fakes.ShimConfigFile.AllInstances.Save = (ConfigFile c) => { };

                var trace = new TraceLogger();
                OrganizationServiceContext ctx = new Microsoft.Xrm.Sdk.Client.Fakes.ShimOrganizationServiceContext();

                var task = new DownloadWebresourceConfigTask(ctx, trace);
                task.Prefix = "new";

                var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                        @"..\..\..\SparkleXrm.Tasks.Tests\Resources");
                // Act
                task.Execute(path);
                return(task);
            }
        }
Example #4
0
        private static void RunTask(CommandLineArgs arguments, IOrganizationService service, ITrace trace)
        {
            if (arguments.Path == null)
            {
                arguments.Path = Directory.GetCurrentDirectory();
            }
            else
            {
                // Strip trailing \
                arguments.Path = arguments.Path.TrimEnd('\\');
                arguments.Path = Path.Combine(Directory.GetCurrentDirectory(), arguments.Path);
            }

            BaseTask task    = null;
            string   command = arguments.Task.ToLower();

            switch (command)
            {
            case "plugins":
                trace.WriteLine("Deploying Plugins");
                task = new DeployPluginsTask(service, trace);
                break;

            case "workflow":
                trace.WriteLine("Deploying Custom Workflow Activities");
                task = new DeployWorkflowActivitiesTask(service, trace);
                break;

            case "webresources":
                trace.WriteLine("Deploying WebResources");
                task = new DeployWebResourcesTask(service, trace);
                break;

            case "instrument":
                trace.WriteLine("Downloading Plugin/Workflow Activity Metadata");
                task = new DownloadPluginMetadataTask(service, trace);
                break;

            case "download-webresources":
                trace.WriteLine("Downloading Webresources");
                task = new DownloadWebresourceFileTask(service, trace)
                {
                    Overwrite = arguments.Overwrite
                };
                break;

            case "get-webresources":
                trace.WriteLine("Downloading Webresources");
                task        = new DownloadWebresourceConfigTask(service, trace);
                task.Prefix = arguments.Prefix;
                break;

            case "earlybound":
                trace.WriteLine("Generating early bound types");
                var earlyBound = new EarlyBoundClassGeneratorTask(service, trace);
                task = earlyBound;
                earlyBound.ConectionString = arguments.Connection;
                break;

            case "unpack":
                trace.WriteLine("Unpacking solution");
                var packager = new SolutionPackagerTask(service, trace);
                packager.command = command;
                task             = packager;
                break;

            case "unpacksolution":
                trace.WriteLine("Unpacking solution Zip");
                var unpackfromsolution = new SolutionPackagerTask(service, trace);
                unpackfromsolution.command = command;
                task = unpackfromsolution;
                break;

            case "pack":
                trace.WriteLine("Packing Solution");
                var pack = new SolutionPackagerTask(service, trace);
                pack.command = command;
                task         = pack;
                break;

            case "import":
                trace.WriteLine("Packing & Import Solution");
                var import = new SolutionPackagerTask(service, trace);
                import.command = command;
                task           = import;
                break;

            case "compare":
                trace.WriteLine("Comparing Solution");
                var compare = new SolutionPackagerTask(service, trace);
                compare.command = command;
                task            = compare;
                break;
            }


            if (task != null)
            {
                if (arguments.Profile != null)
                {
                    task.Profile = arguments.Profile;
                }
                task.Execute(arguments.Path);
            }
            else
            {
                throw new SparkleTaskException(SparkleTaskException.ExceptionTypes.NO_TASK_SUPPLIED, String.Format("Task '{0}' not recognised. Please consult help!", arguments.Task.ToLower()));
            }
        }
Example #5
0
        private static void RunTask(CommandLineArgs arguments, IOrganizationService service, ITrace trace)
        {
            if (arguments.Path == null)
            {
                arguments.Path = Directory.GetCurrentDirectory();
            }
            else
            {
                // Strip trailing \
                arguments.Path = arguments.Path.TrimEnd('\\');
                arguments.Path = Path.Combine(Directory.GetCurrentDirectory(), arguments.Path);
            }

            BaseTask task = null;

            switch (arguments.Task.ToLower())
            {
            case "plugins":
                trace.WriteLine("Deploying Plugins");
                task = new DeployPluginsTask(service, trace);
                break;

            case "workflow":
                trace.WriteLine("Deploying Custom Workflow Activities");
                task = new DeployWorkflowActivitiesTask(service, trace);
                break;

            case "webresources":
                trace.WriteLine("Deploying WebResources");
                task = new DeployWebResourcesTask(service, trace);
                break;

            case "instrument":
                trace.WriteLine("Downloading Plugin/Workflow Activity Metadata");
                task = new DownloadPluginMetadataTask(service, trace);
                break;

            case "get-webresources":
                trace.WriteLine("Downloading Webresources");
                task        = new DownloadWebresourceConfigTask(service, trace);
                task.Prefix = arguments.Prefix;
                break;

            case "earlybound":
                trace.WriteLine("Generating early bound types");
                var earlyBound = new EarlyBoundClassGeneratorTask(service, trace);
                task = earlyBound;
                earlyBound.ConectionString = arguments.Connection;
                break;
            }


            if (task != null)
            {
                if (arguments.Profile != null)
                {
                    task.Profile = arguments.Profile;
                }
                task.Execute(arguments.Path);
            }
            else
            {
                throw new SparkleTaskException(SparkleTaskException.ExceptionTypes.NO_TASK_SUPPLIED, String.Format("Task '{0}' not recognised. Please consult help!", arguments.Task.ToLower()));
            }
        }