Exemplo n.º 1
0
        public void TestGetMissingDependencies_NotInstalled( )
        {
            Solution appA = new Solution
            {
                Name = "appA"
            };
            Solution appB = new Solution
            {
                Name = "appB"
            };
            Solution appC = new Solution
            {
                Name = "appC"
            };

            ApplicationDependency aDependsOnB = new ApplicationDependency
            {
                Name = "appA depends on appB",
                DependentApplication  = appA,
                DependencyApplication = appB
            };

            appA.DependentApplicationDetails.Add(aDependsOnB);

            appA.Save( );

            ApplicationDependency bDependsOnC = new ApplicationDependency
            {
                Name = "appB depends on appC",
                DependentApplication  = appB,
                DependencyApplication = appC
            };

            appB.DependentApplicationDetails.Add(bDependsOnC);

            appB.Save( );

            AppManager.PublishApp(RunAsDefaultTenant.DefaultTenantName, "appA");

            long tenantId = TenantHelper.CreateTenant("ABC");

            AppManager.DeployApp("ABC", Applications.CoreApplicationId.ToString("B"));

            Guid appAUpgradeId = Entity.GetUpgradeId(appA.Id);

            using (new GlobalAdministratorContext( ))
            {
                AppPackage appPackage = SystemHelper.GetLatestPackageByGuid(appAUpgradeId);

                var applicationDependencies = SolutionHelper.GetMissingPackageDependencies(appPackage.Id, tenantId);

                if (applicationDependencies != null && applicationDependencies.Count > 0)
                {
                    Assert.AreEqual(1, applicationDependencies.Count);

                    DependencyFailure dependency = applicationDependencies[0];

                    Assert.AreEqual(DependencyFailureReason.NotInstalled, dependency.Reason);
                }
            }
        }