public void RecordEntryViewModelTestAllFieldTypes()
        {
            var applicationController = new FakeApplicationController();
            var settingsObject        = new SettingsTestAllFieldTypes
            {
                SavedInstances = new[]
                {
                    new TestAllFieldTypes()
                    {
                        StringField = "Foo"
                    }
                }
            };

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

            //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();
        }
Beispiel #2
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);
        }
 public static TestApplication CreateTestApplication(ApplicationControllerBase applicationController = null, ISettingsManager settingsManager = null)
 {
     if(applicationController == null)
         applicationController = new FakeApplicationController();
     if (settingsManager == null)
         settingsManager = new DesktopSettingsManager(applicationController);
     return new TestApplication(applicationController, settingsManager);
 }
        public ObjectEntryViewModel LoadToObjectEntryViewModel(object objectToEnter)
        {
            var applicationController = new FakeApplicationController();
            var recordService         = new ObjectRecordService(objectToEnter, applicationController);
            var formService           = new ObjectFormService(objectToEnter, recordService);
            var viewModel             = new ObjectEntryViewModel(EmptyMethod, EmptyMethod, objectToEnter,
                                                                 new FormController(recordService, formService, applicationController));

            viewModel.LoadFormSections();
            Assert.IsNotNull(viewModel.FormSectionsAsync);
            return(viewModel);
        }
Beispiel #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);
        }