private List <string> GetPackagesPath(string localPath, StoreLayoutSpecification storeLayoutSpecification)
        {
            var packagesPath = new List <string>();
            var manifest     = ImageBuilderUtility.ReadXml <ServiceManifestType>(localPath);

            if (manifest.CodePackage != null)
            {
                foreach (var codePackage in manifest.CodePackage)
                {
                    string packagePath = storeLayoutSpecification.GetCodePackageFolder(this.ApplicationTypeName, manifest.Name, codePackage.Name, codePackage.Version);
                    packagesPath.Add(packagePath);
                }
            }

            if (manifest.ConfigPackage != null)
            {
                foreach (var configPackage in manifest.ConfigPackage)
                {
                    string packagePath = storeLayoutSpecification.GetConfigPackageFolder(this.ApplicationTypeName, manifest.Name, configPackage.Name, configPackage.Version);
                    packagesPath.Add(packagePath);
                }
            }

            if (manifest.DataPackage != null)
            {
                foreach (var dataPackage in manifest.DataPackage)
                {
                    string packagePath = storeLayoutSpecification.GetDataPackageFolder(this.ApplicationTypeName, manifest.Name, dataPackage.Name, dataPackage.Version);
                    packagesPath.Add(packagePath);
                }
            }

            return(packagesPath);
        }
        public void TestValidateNATNetworkPoliciesForManifestGenerationOnOpenForComposeScenario()
        {
            ApplicationTypeInformation applicationTypeInfo = new ApplicationTypeInformation("AppType", "1.0");
            Application app = new Application();

            app.name = "TestApp";
            Management.ImageBuilder.SingleInstance.CodePackage cpkg = new Management.ImageBuilder.SingleInstance.CodePackage();
            cpkg.image = "image";
            cpkg.name  = "CodePackage";
            var endpoints = new List <Endpoint>();
            var endpoint  = new Endpoint();

            endpoint.name = "publicListener";
            endpoint.port = 8080;
            endpoints.Add(endpoint);
            cpkg.endpoints = endpoints;
            var resource = new Resources();
            var req      = new ResourceDescription();

            req.cpu           = 0.5;
            req.memoryInGB    = 1;
            resource.requests = req;
            cpkg.resources    = resource;
            Service svc = new Service();

            svc.properties.codePackages = new List <Management.ImageBuilder.SingleInstance.CodePackage>();
            svc.properties.codePackages.Add(cpkg);
            svc.name = "Svc1";
            NetworkRef nref = new NetworkRef();

            nref.name = StringConstants.NatNetworkName;
            EndpointRef endpointRef = new EndpointRef();

            endpointRef.name  = "publicListener";
            nref.endpointRefs = new List <EndpointRef>()
            {
                endpointRef
            };
            svc.properties.networkRefs = new List <NetworkRef>();
            svc.properties.networkRefs.Add(nref);
            app.properties.services = new List <Service>();
            app.properties.services.Add(svc);

            string applicationTestDir        = Path.Combine(TestUtility.TestDirectory, Guid.NewGuid().ToString());
            string currentExecutingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            this.imageBuilder.BuildSingleInstanceApplication(app, "AppType", "1.0", "TestApp", new Uri("fabric:/TestApp"), false, TimeSpan.MaxValue, applicationTestDir, null, true, false, null, new GenerationConfig());
            string expectedAppManifest = Path.Combine(applicationTestDir, "ApplicationManifest.xml");

            var validatingXmlReaderSettings = new XmlReaderSettings();

            validatingXmlReaderSettings.ValidationType = ValidationType.Schema;
            validatingXmlReaderSettings.Schemas.Add(StringConstants.FabricNamespace, Path.Combine(currentExecutingDirectory, StringConstants.DefaultSchemaPath));
            validatingXmlReaderSettings.XmlResolver = null;
            var applicationManifestType = ImageBuilderUtility.ReadXml <ApplicationManifestType>(expectedAppManifest, validatingXmlReaderSettings);

            ApplicationManifestTypeServiceManifestImport[] servicemanifestimports = applicationManifestType.ServiceManifestImport;
            foreach (var serviceManifestImport in servicemanifestimports)
            {
                var policies = serviceManifestImport.Policies;
                foreach (var policy in policies)
                {
                    if (policy.GetType() == typeof(ContainerHostPoliciesType))
                    {
                        var ContainerHostPoliciesTypeItems = ((ContainerHostPoliciesType)policy).Items;
                        foreach (var item in ContainerHostPoliciesTypeItems)
                        {
                            if (item.GetType() == typeof(PortBindingType))
                            {
                                var portBindingType = (PortBindingType)item;
                                Verify.AreEqual("publicListener", portBindingType.EndpointRef);
                                Verify.AreEqual(8080, portBindingType.ContainerPort);
                            }
                        }
                    }
                }
            }
        }