Exemple #1
0
        public void ExecuteTest()
        {
            var fakeApplicationController = new FakeApplicationController();

            FileUtility.DeleteFiles(fakeApplicationController.SettingsPath);

            var testApplication = TestApplication.CreateTestApplication();

            testApplication.Controller.RegisterType <IDialogController, AutoDialogController>();
            testApplication.AddModule <TSettingsModule>();
            var module = testApplication.GetModule <TSettingsModule>();

            module.DialogCommand();
            var dialog = testApplication.GetNavigatedDialog <TDialog>();

            var settingsFiles = FileUtility.GetFiles(fakeApplicationController.SettingsPath);

            Assert.AreEqual(1, settingsFiles.Count());
            var prismSettingsManager = new PrismSettingsManager(fakeApplicationController);
            var settings             = prismSettingsManager.Resolve <TClass>();

            Assert.IsNotNull(settings);

            module.DialogCommand();
            dialog = testApplication.GetNavigatedDialog <TDialog>();

            settingsFiles = FileUtility.GetFiles(fakeApplicationController.SettingsPath);
            Assert.AreEqual(1, settingsFiles.Count());
            prismSettingsManager = new PrismSettingsManager(fakeApplicationController);
            settings             = prismSettingsManager.Resolve <TClass>();
            Assert.IsNotNull(settings);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            try
            {
                var arguments       = ConsoleApplication.ParseCommandLineArguments(args);
                var applicationName = arguments.ContainsKey("SettingsFolderName") ? arguments["SettingsFolderName"] : "Unknown Console Context";

                //okay need to create app
                var dependencyResolver = new PrismDependencyContainer(new UnityContainer());
                var controller         = new ConsoleApplicationController(applicationName, dependencyResolver);
                var settingsManager    = new PrismSettingsManager(controller);
                var applicationOptions = new ApplicationOptionsViewModel(controller);
                var app = new ConsoleApplication(controller, applicationOptions, settingsManager);
                //load modules in folder path
                app.LoadModulesInExcecutionFolder();
                //run app
                app.Run(args);
                System.Console.WriteLine("Process Completed. Finishing In 10 Seconds");
                Thread.Sleep(10000);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.DisplayString());
                System.Console.WriteLine("Press Any Key To Close");
                System.Console.ReadKey();
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var arguments       = ConsoleApplication.ParseCommandLineArguments(args);
            var applicationName = arguments.ContainsKey("SettingsFolderName") ? arguments["SettingsFolderName"] : "Unknown Console Context";

            //okay need to create app
            var dependencyResolver = new PrismDependencyContainer(new UnityContainer());
            var controller         = new ConsoleApplicationController(applicationName, dependencyResolver);

            try
            {
                var settingsManager    = new PrismSettingsManager(controller);
                var applicationOptions = new ApplicationOptionsViewModel(controller);
                var app = new ConsoleApplication(controller, applicationOptions, settingsManager);
                //load modules in folder path
                app.LoadModulesInExecutionFolder();
                //run app
                app.Run(args);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.DisplayString());
                System.Console.WriteLine("Fatal Error");
                var logFile = new LogFileUserInterface(controller.LogPath, controller.ApplicationName, true, 50);
                logFile.LogMessage($"Fatal Error During Console Execution: {ex.XrmDisplayString()}");
                throw;
            }
        }
        public void RecordEntryViewModelTestAllFieldTypes()
        {
            var applicationController = new FakeApplicationController();
            var settingsObject        = new SettingsTestAllFieldTypes
            {
                SavedInstances = new[]
                {
                    new TestAllFieldTypes()
                    {
                        StringField = "Foo"
                    }
                }
            };

            applicationController.RegisterInstance(typeof(SettingsTestAllFieldTypes), settingsObject);

            var prismSettingsManager = new PrismSettingsManager(applicationController);

            //create the form
            var testObject = new TestAllFieldTypes();

            var lookupService  = FakeRecordService.Get();
            var formController = FormController.CreateForObject(testObject, applicationController, lookupService);
            var entryViewModel = new ObjectEntryViewModel(() => { }, () => { }, testObject, formController);

            //populate all the fields
            entryViewModel.LoadFormSections();
            PopulateRecordEntry(entryViewModel, populateSubgrids: true);

            //save the record
            Assert.IsTrue(entryViewModel.Validate());
            entryViewModel.SaveButtonViewModel.Invoke();
        }
Exemple #5
0
 public static TestApplication CreateTestApplication(ApplicationControllerBase applicationController = null, ISettingsManager settingsManager = null)
 {
     if (applicationController == null)
     {
         applicationController = new FakeApplicationController();
     }
     if (settingsManager == null)
     {
         settingsManager = new PrismSettingsManager(applicationController);
     }
     return(new TestApplication(applicationController, settingsManager));
 }
        public void PrismSettingsManagerTest()
        {
            var fakeApplicationController = new FakeApplicationController();

            FileUtility.DeleteFiles(fakeApplicationController.SettingsPath);
            FileUtility.DeleteSubFolders(fakeApplicationController.SettingsPath);

            var prismSettingsManager = new PrismSettingsManager(fakeApplicationController);

            var resolveNotYetCreated = prismSettingsManager.Resolve <TestResolveType>();

            Assert.IsNotNull(resolveNotYetCreated);
            Assert.AreEqual(0, resolveNotYetCreated.Int);

            resolveNotYetCreated.Int = 50;
            prismSettingsManager.SaveSettingsObject(resolveNotYetCreated);

            var resolveAfterCreation = prismSettingsManager.Resolve <TestResolveType>();

            Assert.AreEqual(resolveNotYetCreated.Int, resolveAfterCreation.Int);
        }
Exemple #7
0
        public void ConsoleApplicationModuleGenerateBatAndExecuteTest()
        {
            //this is done in the load.edit saved request form
            //a button is added the the saved request grid whiuch generates the .bat

            //so we need to save a request
            //then navigate to the save requests and trigger the generate bat button

            var testApplication = CreateThisApp();

            //set to no previously saved ones
            var savedRequests   = new SavedSettings();
            var settingsManager = testApplication.Controller.ResolveType <ISettingsManager>();

            settingsManager.SaveSettingsObject(savedRequests, typeof(TestSavedRequestDialogRequest));

            //navigate to the request and populate the string field
            var entryForm = testApplication.NavigateToDialogModuleEntryForm <TestSavedRequestModule, TestSavedRequestDialog>();
            var request   = new TestSavedRequestDialogRequest()
            {
                SomeArbitraryString = nameof(TestSavedRequestDialogRequest.SomeArbitraryString)
            };

            testApplication.EnterObject(request, entryForm);

            //trigger save request
            var saveRequestButton = entryForm.GetButton("SAVEREQUEST");

            saveRequestButton.Invoke();

            //enter and save details including autoload
            var saveRequestForm = testApplication.GetSubObjectEntryViewModel(entryForm);
            var detailsEntered  = new SaveAndLoadFields()
            {
                Name = "TestName"
            };

            testApplication.EnterAndSaveObject(detailsEntered, saveRequestForm);
            Assert.IsFalse(entryForm.ChildForms.Any());
            Assert.IsFalse(entryForm.LoadingViewModel.IsLoading);

            //reopen app/dialog
            testApplication = CreateThisApp();
            entryForm       = testApplication.NavigateToDialogModuleEntryForm <TestSavedRequestModule, TestSavedRequestDialog>();

            //invoke load request dialog
            var loadRequestButton = entryForm.GetButton("LOADREQUEST");

            loadRequestButton.Invoke();
            var loadRequestForm = testApplication.GetSubObjectEntryViewModel(entryForm);

            //verify there is a saved request and trigger the generate bat button
            var subGrid = loadRequestForm.GetEnumerableFieldViewModel(nameof(SavedSettings.SavedRequests));

            Assert.IsTrue(subGrid.GridRecords.Count() == 1);
            subGrid.GridRecords.First().IsSelected = true;

            var generateBatButton = subGrid.DynamicGridViewModel.GetButton("GENERATEBAT");

            generateBatButton.Invoke();

            var testFiles = FileUtility.GetFiles(TestingFolder);

            Assert.AreEqual(1, testFiles.Count());
            Assert.IsTrue(testFiles.First().EndsWith(".bat"));

            var batContent = File.ReadAllText(testFiles.First());

            var args = ConsoleTestUtility.CommandLineToArgs(batContent)
                       .Skip(1)
                       .ToArray();

            var arguments       = ConsoleApplication.ParseCommandLineArguments(args);
            var applicationName = arguments.ContainsKey("SettingsFolderName") ? arguments["SettingsFolderName"] : "Unknown Console Context";

            //okay need to create app
            var dependencyResolver = new PrismDependencyContainer(new UnityContainer());
            var controller         = new ConsoleApplicationController(applicationName, dependencyResolver);

            settingsManager = new PrismSettingsManager(controller);
            var applicationOptions = new ApplicationOptionsViewModel(controller);
            var app = new ConsoleApplication(controller, applicationOptions, settingsManager);

            //load modules in folder path
            app.LoadModulesInExecutionFolder();
            //run app
            app.Run(args);
        }