public void VsixSolutionWizardTest()
        {
            //okay so this wizard contains a dialog spawned different to the others
            //since it is loaded prior to the solution being created
            //this script just verifies the settings are netered into the dialog wihtout a crash with no visual studio solutoion context etc.


            var packageSettings = new XrmPackageSettings();

            var container = new VsixDependencyContainer();

            //purpose of this is to load modules registrations into the container as per done in the actual wizard
            Factory.CreateJosephMXrmVsixApp(new FakeVisualStudioService(), container, isNonSolutionExplorerContext: true);

            //okay spawn the wizards entry method with a fake controller
            var applicationController = new FakeVsixApplicationController(container);

            XrmSolutionWizardBase.RunWizardSettingsEntry(packageSettings, applicationController, "Fake.Name");

            //okay so now we have navigated to the package entry
            //in our application controller via the wizard

            //here I inject that application conctroller into a fake application
            //so that I can use methods for auto testing the dialog which has spawned
            var fakeVsixApplication = TestApplication.CreateTestApplication(applicationController);

            fakeVsixApplication.AddModule <XrmPackageSettingsModule>();
            var dialog = fakeVsixApplication.GetNavigatedDialog <XrmPackageSettingsDialog>();

            //okay so the package entry dialog should redirect us to the connection entry when started as we dont have a connection yet
            var connectionEntryDialog = dialog.SubDialogs.First();
            var connectionEntry       = fakeVsixApplication.GetSubObjectEntryViewModel(connectionEntryDialog);

            var connectionToEnter = GetXrmRecordConfiguration();

            fakeVsixApplication.EnterAndSaveObject(connectionToEnter, connectionEntry);

            //okay now the connection is entered it should navigate to the package settings entry
            var packageSettingsEntry = fakeVsixApplication.GetSubObjectEntryViewModel(dialog, index: 1);

            Assert.AreEqual("Fake", packageSettingsEntry.GetStringFieldFieldViewModel(nameof(XrmPackageSettings.SolutionObjectPrefix)).Value);

            //we want to verify that the object had the settings passed into it as well as the lookup connection works
            packageSettingsEntry.GetBooleanFieldFieldViewModel(nameof(XrmPackageSettings.AddToSolution)).Value = true;
            var solutionPicklistField = packageSettingsEntry.GetLookupFieldFieldViewModel(nameof(XrmPackageSettings.Solution));

            solutionPicklistField.SelectedItem = solutionPicklistField.ItemsSource.ElementAt(1);
            Assert.IsTrue(!string.IsNullOrWhiteSpace(packageSettingsEntry.GetStringFieldFieldViewModel(nameof(XrmPackageSettings.SolutionDynamicsCrmPrefix)).Value));

            var connectionsubGrid = packageSettingsEntry.GetEnumerableFieldViewModel(nameof(XrmPackageSettings.Connections));

            Assert.IsTrue(connectionsubGrid.GridRecords.Any());
            Assert.AreEqual(connectionToEnter.OrganizationUniqueName, connectionsubGrid.GridRecords.First().GetStringFieldFieldViewModel(nameof(SavedXrmRecordConfiguration.OrganizationUniqueName)).Value);

            packageSettingsEntry.SaveButtonViewModel.Invoke();

            Assert.IsTrue(packageSettings.Connections.Any());
            Assert.AreEqual(connectionToEnter.OrganizationUniqueName, packageSettings.Connections.First().OrganizationUniqueName);
        }
예제 #2
0
        public void VsixSolutionWizardTest()
        {
            //okay so this wizard contains a dialog spawned different to the others
            //since it is loaded prior to the solution being created
            //this script just verifies the settings are netered into the dialog wihtout a crash with no visual studio solutoion context etc.


            var packageSettings = new XrmPackageSettings
            {
                SolutionDynamicsCrmPrefix = "FAKE",
                SolutionObjectPrefix      = "Fake"
            };
            //okay spawn the wizards entry method with a fake controller
            var container             = new VsixDependencyContainer();
            var applicationController = new FakeVsixApplicationController(container);

            XrmSolutionWizardBase.RunWizardSettingsEntry(packageSettings, applicationController);

            //fake applcation simply to use its navigation and entry methods
            var fakeVsixApplication = TestApplication.CreateTestApplication(applicationController);

            //okay so the package entry dialgo should redirect us to the conneciton entry when started as we don;t have a connection yet
            var dialog = fakeVsixApplication.GetNavigatedDialog <XrmPackageSettingsDialog>();
            var connectionEntryDialog = dialog.SubDialogs.First();
            var connectionEntry       = fakeVsixApplication.GetSubObjectEntryViewModel(connectionEntryDialog);

            var connectionToEnter = GetXrmRecordConfiguration();

            fakeVsixApplication.EnterAndSaveObject(connectionToEnter, connectionEntry);

            //okay now the conneciton is entered it should navigate to the package settings entry
            var packageSettingsEntry = fakeVsixApplication.GetSubObjectEntryViewModel(dialog, index: 1);

            //we want to verify that the object had the settings passed into it as well as the lookup connection works
            packageSettingsEntry.GetBooleanFieldFieldViewModel(nameof(XrmPackageSettings.AddToSolution)).Value = true;
            var solutionPicklistField = packageSettingsEntry.GetLookupFieldFieldViewModel(nameof(XrmPackageSettings.Solution));

            solutionPicklistField.SelectedItem = solutionPicklistField.ItemsSource.First();

            var connectionsubGrid = packageSettingsEntry.GetEnumerableFieldViewModel(nameof(XrmPackageSettings.Connections));

            Assert.IsTrue(connectionsubGrid.GridRecords.Any());
            Assert.AreEqual(connectionToEnter.OrganizationUniqueName, connectionsubGrid.GridRecords.First().GetStringFieldFieldViewModel(nameof(SavedXrmRecordConfiguration.OrganizationUniqueName)).Value);

            packageSettingsEntry.SaveButtonViewModel.Invoke();

            Assert.IsTrue(packageSettings.Connections.Any());
            Assert.AreEqual(connectionToEnter.OrganizationUniqueName, packageSettings.Connections.First().OrganizationUniqueName);

            if (applicationController.GetObjects().Any())
            {
                Assert.Inconclusive("Haven't verified closure of the form after entry instead of navigation to completion screen");
            }
        }
        public ApplicationControllerBase CreateTestVsixApplicationController()
        {
            var container           = new PrismDependencyContainer(new UnityContainer());
            var visualStudioService = VisualStudioService;

            container.RegisterInstance(typeof(IVisualStudioService), visualStudioService);
            container.RegisterInstance(typeof(ISettingsManager), new VsixSettingsManager(visualStudioService));
            var applicationController = new FakeVsixApplicationController(container);

            return(applicationController);
        }
예제 #4
0
        protected override TestApplication CreateAndLoadTestApplication <TModule>(ApplicationControllerBase applicationController = null, ISettingsManager settingsManager = null, bool loadXrmConnection = true, bool addSavedConnectionAppConnectionModule = false)
        {
            var container           = new VsixDependencyContainer();
            var visualStudioService = VisualStudioService;

            container.RegisterInstance(typeof(IVisualStudioService), visualStudioService);
            var vsixController      = new FakeVsixApplicationController(container);
            var vsixSettingsManager = new VsixSettingsManager(VisualStudioService, new DesktopSettingsManager(vsixController));

            container.RegisterInstance(typeof(ISettingsManager), vsixSettingsManager);
            var app = base.CreateAndLoadTestApplication <TModule>(vsixController, vsixSettingsManager, loadXrmConnection: InitialiseModuleXrmConnection, addSavedConnectionAppConnectionModule: addSavedConnectionAppConnectionModule);

            app.AddModule <PackageSettingsAppConnectionModule>();
            return(app);
        }