Example #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);
        }
        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);
        }