public void Test_Setup()
        {
            using (LogGroup logGroup = LogGroup.StartDebug("Testing the ApplicationInstaller.Setup function."))
            {
                CreateDummyVersionFile(TestUtilities.GetTestApplicationPath(this, "MockApplication"));

                User admin = new User();
                admin.ID        = Guid.NewGuid();
                admin.Username  = "******";
                admin.Password  = Crypter.EncryptPassword("pass");
                admin.Validator = ValidateStrategy.New(admin);

                ApplicationInstaller installer = new ApplicationInstaller();
                installer.ApplicationPath         = "/MockApplication";
                installer.Administrator           = admin;
                installer.AdministratorRoleName   = "Administrator";
                installer.PathVariation           = "testing";
                installer.FileMapper              = new MockFileMapper(this);
                installer.DataProviderInitializer = new MockDb4oDataProviderInitializer(this);
                installer.EnableTesting           = true;
                installer.Setup();

                User foundAdministrator = DataAccess.Data.Reader.GetEntity <User>("ID", admin.ID);

                DataAccess.Data.Activator.Activate(foundAdministrator);

                Assert.AreEqual(1, foundAdministrator.Roles.Length, "The administrator user isn't in the administrator role.");
            }
        }
Пример #2
0
        public void TestInstallMultipleFiles()
        {
            var descriptor = new ApplicationDescriptor
            {
                Name = "TestInstallSingleFile",
            };

            InstalledApplication app;

            using (var installer = new ApplicationInstaller(_watchdog, descriptor))
            {
                installer.AddFiles(_binFolder, Environment.SpecialFolder.CommonDocuments);
                app = installer.Commit();
            }

            string[]             expectedFiles = Directory.GetFiles(_binFolder);
            List <InstalledFile> actualFiles   = app.Files;

            actualFiles.Count.Should().Be(expectedFiles.Length);
            for (int i = 0; i < expectedFiles.Length; ++i)
            {
                string fullPath = InternalWatchdog.Resolve(descriptor.Name, Environment.SpecialFolder.CommonDocuments,
                                                           actualFiles[i].Filename);
                FilesAreEqual(new FileInfo(expectedFiles[i]), new FileInfo(fullPath));
            }
        }
Пример #3
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));
            }
        }
Пример #4
0
 /// <summary>
 /// Creates new installation context.
 /// </summary>
 public void CreateInstallationContext(string ProductID, string InstanceID = null, string OfferID = null, bool noUninstall = false, bool preInstall = false, byte[] license = null)
 {
     if (OfferID != null || license != null)
     {
         this.license = true;
     }
     _context = new ApplicationInstaller(_fileName, ProductID, InstanceID, OfferID, noUninstall, preInstall, license);
 }
Пример #5
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));
        }
Пример #6
0
        public void TestInitialize()
        {
            _shimsObject = ShimsContext.Create();
            SharepointShims.ShimSharepointCalls();
            _shimAdo = AdoShims.ShimAdoNetCalls();

            ArrangeShims();

            _applicationInstaller = new ApplicationInstaller(
                string.Empty,
                new ShimSqlConnection().Instance,
                new ShimInstallAndConfigure().Instance);

            _privateObject = new PrivateObject(_applicationInstaller);
        }
Пример #7
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);
        }
Пример #8
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));
        }
        public void Test_IsInstalled_false()
        {
            string applicationName = "TestApplication";

            string applicationPath = TestUtilities.GetTestApplicationPath(this, applicationName);

            string pathVariation = "testing";

            string appConfigPath = TestUtilities.GetTestDataPath(this, applicationName) + Path.DirectorySeparatorChar + "Application." + pathVariation + ".config";

            ApplicationInstaller installer = new ApplicationInstaller();
            installer.ApplicationPath = applicationName;
            installer.PathVariation = pathVariation;
            installer.FileMapper = new MockFileMapper(this,TestUtilities.GetTestingPath(this));

            bool isInstalled = installer.IsInstalled;

            Assert.IsFalse(isInstalled, "Returned true when it should have returned false.");
        }
        public void Test_InitializeVersion()
        {
            string applicationName = "TestApplication";

            string fullApplicationPath = TestUtilities.GetTestApplicationPath(this, applicationName);

            VersionTestUtilities.CreateDummyVersion(fullApplicationPath, String.Empty);

            ApplicationInstaller installer = new ApplicationInstaller();
            installer.ApplicationPath = applicationName;
            installer.FileMapper = new MockFileMapper(this,TestUtilities.GetTestingPath(this));
            installer.InitializeVersion();

            string versionFile = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar
                + applicationName + Path.DirectorySeparatorChar
                + installer.DataDirectory + Path.DirectorySeparatorChar
                + "Version.number";

            Assert.IsTrue(File.Exists(versionFile), "The version file wasn't found in the data directory.");
        }
        public void Test_IsInstalled_false()
        {
            string applicationName = "TestApplication";

            string applicationPath = TestUtilities.GetTestApplicationPath(this, applicationName);

            string pathVariation = "testing";

            string appConfigPath = TestUtilities.GetTestDataPath(this, applicationName) + Path.DirectorySeparatorChar + "Application." + pathVariation + ".config";


            ApplicationInstaller installer = new ApplicationInstaller();

            installer.ApplicationPath = applicationName;
            installer.PathVariation   = pathVariation;
            installer.FileMapper      = new MockFileMapper(this, TestUtilities.GetTestingPath(this));

            bool isInstalled = installer.IsInstalled;

            Assert.IsFalse(isInstalled, "Returned true when it should have returned false.");
        }
Пример #12
0
        public void TestInstallSingleFile()
        {
            var descriptor = new ApplicationDescriptor
            {
                Name = "TestInstallSingleFile",
            };
            string fullPath = InternalWatchdog.Resolve(descriptor.Name, Environment.SpecialFolder.CommonApplicationData,
                                                       "SharpRemote.dll");
            var original = new FileInfo(_sharpRemoteLibraryLocation);

            if (File.Exists(fullPath))
            {
                File.Delete(fullPath);
            }

            InstalledApplication app;

            using (var installer = new ApplicationInstaller(_watchdog, descriptor))
            {
                installer.AddFile(_sharpRemoteLibraryLocation, Environment.SpecialFolder.CommonApplicationData);
                app = installer.Commit();
            }

            app.Descriptor.Should().Be(descriptor);
            app.Files.Count.Should().Be(1);
            InstalledFile file = app.Files[0];

            file.Id.Should().Be(1);
            file.Folder.Should().Be(Environment.SpecialFolder.CommonApplicationData);
            file.Filename.Should().Be("SharpRemote.dll");
            file.FileLength.Should().Be(original.Length);

            var copy = new FileInfo(fullPath);

            copy.Exists.Should().BeTrue("Because the file should've been created during the installation");
            copy.Length.Should().Be(file.FileLength);

            FilesAreEqual(original, copy).Should().BeTrue();
        }
        public void Test_InitializeVersion()
        {
            string applicationName = "TestApplication";

            string fullApplicationPath = TestUtilities.GetTestApplicationPath(this, applicationName);

            VersionTestUtilities.CreateDummyVersion(fullApplicationPath, String.Empty);

            ApplicationInstaller installer = new ApplicationInstaller();

            installer.ApplicationPath = applicationName;
            installer.FileMapper      = new MockFileMapper(this, TestUtilities.GetTestingPath(this));
            installer.InitializeVersion();


            string versionFile = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar
                                 + applicationName + Path.DirectorySeparatorChar
                                 + installer.DataDirectory + Path.DirectorySeparatorChar
                                 + "Version.number";

            Assert.IsTrue(File.Exists(versionFile), "The version file wasn't found in the data directory.");
        }
Пример #14
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));
        }
Пример #15
0
        public ViewModelLocator()
        {
            //var applicationInstaller = new ApplicationInstaller(
            //    @"Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;Initial Catalog = ContactManager;");

            var applicationInstaller = new ApplicationInstaller();

            var builder = new ContainerBuilder();

            applicationInstaller.ComposeApplication(builder);

            builder.RegisterModule <UiModule>();

            Container = builder.Build();

            if (ViewModelBase.IsInDesignModeStatic)
            {
            }
            else
            {
                applicationInstaller.EnsureDatabaseCreation();
            }
        }
Пример #16
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);
        }
        public void Test_Setup()
        {
            using (LogGroup logGroup = LogGroup.StartDebug("Testing the ApplicationInstaller.Setup function."))
            {
                CreateDummyVersionFile(TestUtilities.GetTestApplicationPath(this, "MockApplication"));

                User admin = new User();
                admin.ID = Guid.NewGuid();
                admin.Username = "******";
                admin.Password = Crypter.EncryptPassword("pass");
                admin.Validator = ValidateStrategy.New(admin);

                ApplicationInstaller installer = new ApplicationInstaller();
                installer.ApplicationPath = "/MockApplication";
                installer.Administrator = admin;
                installer.AdministratorRoleName = "Administrator";
                installer.PathVariation = "testing";
                installer.FileMapper = new MockFileMapper(this);
                installer.DataProviderInitializer = new MockDb4oDataProviderInitializer(this);
                installer.EnableTesting = true;
                installer.Setup();

                User foundAdministrator = DataAccess.Data.Reader.GetEntity<User>("ID", admin.ID);

                DataAccess.Data.Activator.Activate(foundAdministrator);

                Assert.AreEqual(1, foundAdministrator.Roles.Length, "The administrator user isn't in the administrator role.");
            }
        }