Пример #1
0
        public async Task TestUpdateApplication()
        {
            IApplicationPool      applicationPool      = new ApplicationPoolStub();
            IApplicationInstaller applicationInstaller = new ApplicationInstaller(_applicationsRoot, new ApplicationFactoryStub(), applicationPool);

            const string appId = "test.app";

            AppIdentity[] existingApps = { new AppIdentity(appId, new SemVersion(1, 0, 0)), new AppIdentity(appId, new SemVersion(1, 0, 1)) };
            AppIdentity[] newApps      = { new AppIdentity(appId, new SemVersion(1, 0, 2)), new AppIdentity(appId, new SemVersion(2, 0, 0)) };

            foreach (var existingApp in existingApps)
            {
                string appPath = Path.Combine(_applicationsRoot, existingApp.Id, existingApp.Version.ToString());
                if (!Directory.Exists(appPath))
                {
                    Directory.CreateDirectory(appPath);
                }
                await applicationInstaller.Install(new AppInstallConfig(existingApp));

                Assert.True(applicationPool.HasApplication(existingApp));
            }

            await applicationInstaller.Update(existingApps, newApps.Select(appIdentity => new AppInstallConfig(appIdentity)));

            foreach (AppIdentity app in existingApps)
            {
                Assert.False(applicationPool.HasApplication(app));
            }

            foreach (AppIdentity app in newApps)
            {
                Assert.True(applicationPool.HasApplication(app));
            }
        }
Пример #2
0
        public async Task TestInstallApplication()
        {
            _applicationPool = new ApplicationPoolStub();
            IApplicationFactory applicationFactory = new ApplicationFactoryStub();

            _applicationInstaller = new ApplicationInstaller(_applicationsRoot, null, applicationFactory, _applicationPool);

            AppIdentity appIdentity = new AppIdentity("test.app", new Version(1, 0, 0));
            await _applicationInstaller.Install(appIdentity);

            Assert.IsTrue(_applicationPool.HasApplicationBeenAdded(appIdentity));
        }
Пример #3
0
        private bool Install(InstallThreadParam param)
        {
            if (_context.IsValidContext() == true)
            {
                bool result    = false;
                bool debugMode = true;
                if (license)
                {
                    debugMode = false;
                }
                if (param.operation == XapInstallOperationType.Install)
                {
                    result = _context.Install(debugMode);
                }
                else if (param.operation == XapInstallOperationType.Update)
                {
                    result = _context.Update(debugMode);
                }
                else
                {
                    result = _context.Uninstall();
                }

                if (result && param.report)
                {
                    while (true)
                    {
                        ApplicationEvent evt = _context.WaitForEvent();
                        if (StateChanged != null)
                        {
                            XapInstallEventArgs e = new XapInstallEventArgs();
                            e.application = _context;
                            e.fileName    = param.fileName;
                            e.progress    = evt.progress;
                            e.state       = evt.state;
                            e.error       = evt.error;
                            Deployment.Current.Dispatcher.BeginInvoke(delegate() { StateChanged(this, e); });
                        }
                        if ((evt.state == InstallationState.AppInstallCompleted && param.operation == XapInstallOperationType.Install) ||
                            (evt.state == InstallationState.AppUpdateCompleted && param.operation == XapInstallOperationType.Update) ||
                            (evt.state == InstallationState.AppRemoveCompleted && param.operation == XapInstallOperationType.Uninstall))
                        {
                            break;
                        }
                    }
                }
                return(result);
            }
            return(false);
        }
Пример #4
0
        public async Task TestUpdateApplication()
        {
            string updateSessionId = null;
            IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager()
            {
                TryStartUpdateSessionString = id =>
                {
                    updateSessionId = id;
                    return(Task.FromResult(true));
                },
                EndUpdateSessionString = id => Task.FromResult(true)
            };

            IApplicationPool      applicationPool      = new ApplicationPoolStub();
            IApplicationInstaller applicationInstaller = new ApplicationInstaller(_applicationsRoot, updateSessionManager, new ApplicationFactoryStub(), applicationPool);

            const string appId = "test.app";

            AppIdentity[] existingApps = { new AppIdentity(appId, new Version(1, 0, 0)), new AppIdentity(appId, new Version(1, 0, 1)) };
            AppIdentity[] newApps      = { new AppIdentity(appId, new Version(1, 0, 2)), new AppIdentity(appId, new Version(2, 0, 0)) };

            foreach (var existingApp in existingApps)
            {
                string appPath = Path.Combine(_applicationsRoot, existingApp.Id, existingApp.Version.ToString());
                if (!Directory.Exists(appPath))
                {
                    Directory.CreateDirectory(appPath);
                }
                await applicationInstaller.Install(existingApp);

                Assert.IsTrue(applicationPool.HasApplication(existingApp));
            }

            await applicationInstaller.Update(appId, existingApps.Select(app => app.Version), newApps.Select(app => app.Version));

            foreach (AppIdentity app in existingApps)
            {
                Assert.IsFalse(applicationPool.HasApplication(app));
            }

            foreach (AppIdentity app in newApps)
            {
                Assert.IsTrue(applicationPool.HasApplication(app));
            }

            Assert.AreEqual(appId, updateSessionId);
        }
Пример #5
0
        public async Task TestThatUpdateReturnsIfCannotStartUpdateSession()
        {
            IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager()
                                                         .TryStartUpdateSession(id => Task.FromResult(false));

            IApplicationPool      applicationPool      = new ApplicationPoolStub();
            IApplicationInstaller applicationInstaller = new ApplicationInstaller(_applicationsRoot, updateSessionManager, new ApplicationFactoryStub(), applicationPool);

            AppIdentity existingApp = new AppIdentity("test.app", new SemVersion(1, 0, 0));
            await applicationInstaller.Install(new AppInstallConfig(existingApp));

            AppIdentity newApp = new AppIdentity(existingApp.Id, new SemVersion(1, 1, 0));
            await applicationInstaller.Update(new[] { existingApp }, new[] { new AppInstallConfig(newApp), });

            Assert.True(applicationPool.HasApplication(existingApp));
            Assert.False(applicationPool.HasApplication(newApp));
        }
Пример #6
0
        public async Task TestRemoveApplication()
        {
            _applicationPool = new ApplicationPoolStub();
            IApplicationFactory applicationFactory = new ApplicationFactoryStub();

            _applicationInstaller = new ApplicationInstaller(_applicationsRoot, null, applicationFactory, _applicationPool);

            AppIdentity appIdentity = new AppIdentity("test.app", new Version(1, 0, 0));

            _applicationInstaller.Install(appIdentity).Wait();

            // make sure the app directory exists because uninstall will try to delete it
            string appPath = Path.Combine(_applicationsRoot, "test.app", "1.0.0");

            if (!Directory.Exists(appPath))
            {
                Directory.CreateDirectory(appPath);
            }
            await _applicationInstaller.UnInstall(appIdentity);

            Assert.IsFalse(_applicationPool.HasApplication(appIdentity));
            Assert.IsFalse(Directory.Exists(appPath));
        }
Пример #7
0
        public void Setup()
        {
            //var path = @"D:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Data\Sicemed_Snapshot.ss";
            var path = @"C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Sicemed_Snapshot.ss";
            CreateDatabaseSnapshot("Sicemed_Snapshot", "SicemedTest", path);
            var logLevel = LogManager.GetRepository().Threshold;
            LogManager.GetRepository().Threshold = Level.Off;

            CurrentSessionContext.Bind(SessionFactory.OpenSession());

            var installer = new ApplicationInstaller();
            installer.SessionFactory = SessionFactory;

            var membershipMailerMock = new Mock<IMembershipMailer>();
            membershipMailerMock.SetReturnsDefault(new MailMessage("*****@*****.**", "*****@*****.**"));

            installer.MembershipService = new MembershipService(SessionFactory,
                                                                membershipMailerMock.Object,
                                                                new Mock<IFormAuthenticationStoreService>().Object);
            installer.Install(DatabaseConfiguration);

            LogManager.GetRepository().Threshold = logLevel;

            new RijndaelEngine("WAL");
            _membershipMailer = new Mock<IMembershipMailer>();
            _membershipMailer.SetReturnsDefault(new MailMessage("*****@*****.**", "*****@*****.**"));
            var formsService = new Mock<IFormAuthenticationStoreService>();
            _membershipService = new MembershipService(SessionFactory,
                                                       _membershipMailer.Object,
                                                       formsService.Object);
        }