Exemplo n.º 1
0
        public void GetManifest_ManyVersions_GetsCorrectVersion()
        {
            IFileSystem fileSystem = Substitute.For <IFileSystem>();

            fileSystem.OpenRead(Arg.Any <string>()).Returns(GetValidStreamManyVersions());

            this.sut = new JsonFileProductManifestRepository(fileSystem);
            ProductManifest result = this.sut.GetManifest("otherProduct", "1.1.0");

            Assert.NotNull(result);
        }
Exemplo n.º 2
0
        public void GetManifest_VersionNotFound_ReturnsNull()
        {
            IFileSystem fileSystem = Substitute.For <IFileSystem>();

            fileSystem.OpenRead(Arg.Any <string>()).Returns(GetValidStream());

            this.sut = new JsonFileProductManifestRepository(fileSystem);
            ProductManifest result = this.sut.GetManifest("someProduct", "1.999.0");

            Assert.Null(result);
        }
Exemplo n.º 3
0
        public void GetManifest_NullVersion_Succeeds()
        {
            File.Copy($"../../../testdata/{ManifestFilename}", ManifestFilename, true);

            this.sut = new JsonFileProductManifestRepository(new FileSystem());

            ProductManifest result = this.sut.GetManifest("someProduct", null);

            Assert.NotNull(result);

            File.Delete(ManifestFilename);
        }
Exemplo n.º 4
0
        public void Deploy_HasBranch_UsesBranch()
        {
            IProductManifestRepository manifestRepository = Substitute.For <IProductManifestRepository>();
            IServiceDeploymentHandler  deploymentHandler  = Substitute.For <IServiceDeploymentHandler>();

            ProductManifest testManifest = GetTestManifest(2);

            manifestRepository.GetManifest(Arg.Any <string>(), Arg.Any <string>())
            .Returns(testManifest);
            this.sut = new DeploymentService(manifestRepository, deploymentHandler);
            this.sut.Deploy("someProduct", "someEnvironment", "someVersion", "someBranch");

            deploymentHandler.Received()
            .Deploy(testManifest, "someEnvironment", "someVersion", "someBranch");
        }
Exemplo n.º 5
0
        public void Deploy(
            ProductManifest productManifest,
            string environment,
            string version = null,
            string branch  = null)
        {
            if (productManifest == null)
            {
                throw new ArgumentNullException(nameof(productManifest));
            }
            if (string.IsNullOrWhiteSpace(environment))
            {
                throw new ArgumentException("parameter cannot be null or whitespace", nameof(environment));
            }

            ProductVersion productVersion = productManifest.Versions.FirstOrDefault(
                v => v.Version == version);

            if (productVersion == null)
            {
                return;
            }

            foreach (Service service in productVersion.Services)
            {
                if (this.StartDeployment(
                        service,
                        environment,
                        branch,
                        productManifest.PrereqEnvironment))
                {
                    if (this.options == null || !this.options.WhatIf)
                    {
                        DeploymentStatus status =
                            this.WaitForDeploymentComplete(service, environment);

                        if (status != DeploymentStatus.Succeeded)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 6
0
        private ProductManifest GetTestManifest(int count)
        {
            IList <Service> services = new List <Service>();

            for (int i = 0; i < count; i++)
            {
                services.Add(new Service($"service{i}", "someVersion"));
            }

            ProductVersion version = new ProductVersion("someVersion", services);

            ProductManifest catalogue =
                new ProductManifest("someproduct", null, new ProductVersion[] { version });

            return(catalogue);
        }
Exemplo n.º 7
0
        private ProductManifest GetTestManifest(int count)
        {
            IList <Service> services = new List <Service>();

            for (int i = 0; i < count; i++)
            {
                services.Add(new Service($"service{i}", "someVersion"));
            }

            ProductManifest manifest =
                new ProductManifest(
                    "someproduct",
                    null,
                    new ProductVersion[] { new ProductVersion("someVersion", services) });

            return(manifest);
        }
Exemplo n.º 8
0
        public void Deploy(
            string productName,
            string environment,
            string productVersion = null,
            string branch         = null)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(productName))
                {
                    throw new ArgumentException("parameter cannot be null or whitespace", nameof(productName));
                }
                if (string.IsNullOrWhiteSpace(environment))
                {
                    throw new ArgumentException("parameter cannot be null or whitespace", nameof(environment));
                }
                if (branch == null)
                {
                    branch = DefaultBranch;
                }

                this.logger.LogDebug("starting");

                ProductManifest productManifest = this.manifestRepository.GetManifest(productName, productVersion);

                if (productManifest == null)
                {
                    this.logger.LogWarning($"could not find product:[{productName}] with version:[{productVersion}] in the manifest");
                    return;
                }

                this.deploymentHandler.Deploy(
                    productManifest,
                    environment,
                    productVersion: productVersion,
                    branch: branch);
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex, "application exception");
                throw;
            }
        }
        public void ProductTest()
        {
            Product theProduct = new Product
            {
                Manifest = "Manifest.xml",
                Name     = "Macro Test",
                Suffix   = "SP1",
                Version  = "1.2.12011.33333"
            };

            ProductManifest theManfest = new ProductManifest
            {
                Product = theProduct
            };

            ManifestFile theFile = new ManifestFile
            {
                Checksum  = "111",
                Filename  = "Test.dll",
                Timestamp = DateTime.Now
            };

            theManfest.Files.Add(theFile);

            MacroManifest manifest = new MacroManifest
            {
                ProductManifest = theManfest
            };

            XmlSerializer theSerializer = new XmlSerializer(typeof(MacroManifest));

            using (FileStream fs = new FileStream("ProductTest.xml", FileMode.Create))
            {
                XmlWriter writer = XmlWriter.Create(fs);
                if (writer != null)
                {
                    theSerializer.Serialize(writer, manifest);
                }
                fs.Flush();
                fs.Close();
            }
        }
Exemplo n.º 10
0
        private static ProductManifest GetProductManifest(
            Manifest manifest, string product, string version)
        {
            ProductManifest productManifest = manifest.Products.FirstOrDefault(
                p => p.Name.Equals(product, StringComparison.InvariantCultureIgnoreCase));

            if (productManifest == null)
            {
                return(null);
            }

            if (!productManifest.Versions.Any(v => v.Version == version))
            {
                return(null);
            }

            return(new ProductManifest(
                       productManifest.Name,
                       productManifest.PrereqEnvironment,
                       productManifest.Versions.Where(v => v.Version == version)));
        }
Exemplo n.º 11
0
		public void ProductTest()
		{
            Product theProduct = new Product
                                     {
                                         Manifest = "Manifest.xml",
                                         Name = "ClearCanvas Test",
                                         Suffix = "SP1",
                                         Version = "1.2.12011.33333"
                                     };

		    ProductManifest theManfest = new ProductManifest
		                                     {
		                                         Product = theProduct
		                                     };

		    ManifestFile theFile = new ManifestFile
		                               {
		                                   Checksum = "111",
		                                   Filename = "Test.dll",
		                                   Timestamp = DateTime.Now
		                               };

		    theManfest.Files.Add(theFile);

            ClearCanvasManifest manifest = new ClearCanvasManifest
                                               {
                                                   ProductManifest = theManfest
                                               };

		    XmlSerializer theSerializer = new XmlSerializer(typeof(ClearCanvasManifest));

            using (FileStream fs = new FileStream("ProductTest.xml", FileMode.Create))
            {
                XmlWriter writer = XmlWriter.Create(fs);
                if (writer != null)
                    theSerializer.Serialize(writer, manifest);
                fs.Flush();
                fs.Close();
            }
		}
Exemplo n.º 12
0
 public void Ctor_NullServices_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(() => this.sut = new ProductManifest("someProduct", null, null));
 }
Exemplo n.º 13
0
 public void Ctor_NullName_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
                                       this.sut = new ProductManifest(null, null, GetTestVerion(1)));
 }
Exemplo n.º 14
0
        bool Validate(ref  ProductManifest prm)
        {
            FormCollection collection = new FormCollection(ConvertRawUrlToQuerystring());



            prm.code_To_Display = collection[UIProduct.txtCodeToDisplay.ToString()];
            prm.code_To_DisplayError = "";
            prm.product_Code = collection[UIProduct.txtProduct_Code.ToString()];
            prm.product_CodeError = "";

            prm.file_Name = collection[UIProduct.hidFileName.ToString()];
            prm.file_NameError = "";

            prm.code_To_Display = collection[UIProduct.txtCodeToDisplay.ToString()];
            prm.code_To_DisplayError= "";

            prm.product = collection[UIProduct.txtProduct.ToString()];
            prm.productError = "";

            prm.product_Type = Convert.ToInt32( collection[UIProduct.cobProductType.ToString()] );
            prm.product_TypeError = "";


            prm.description = collection[UIProduct.txtDescription.ToString()];
            prm.descriptionError = "";

            prm.product_Link = collection[UIProduct.txtLink.ToString()];
            prm.product_LinkError = "";

            prm.product_ID = collection[UIProduct.hidProduct_ID.ToString()];

            if (collection[UIProduct.is_Active.ToString()] == null)
            {
                prm.is_Active = false;
            }
            else
            {
                prm.is_Active = true;
            }

            


            if (collection[UIProduct.is_Active.ToString()] == null)
            {
                prm.is_Active = false;
            }
            else
            {
                prm.is_Active = true;
            }



            prm.hidState = Convert.ToInt32( collection[UIProduct.hidState.ToString()] );
            

            if ( prm.code_To_Display.Trim().Length == 0  )
            {
                prm.code_To_DisplayError = "Enter valid display code";
                prm.Has_Error= true;
            }


            if ( prm.file_Name.Trim().Length == 0  )
            {
                prm.file_NameError= "select product image";
                prm.Has_Error= true;
            }

            if ( prm.product.Trim().Length == 0  )
            {
                prm.productError= "Enter product name";
                prm.Has_Error= true;
            }

            if ( prm.product_Code.Trim().Length == 0  )
            {
                prm.product_CodeError= "Enter Product Code In AccPac";
                prm.Has_Error= true;
            }

            if ( prm.product_Type == 0  )
            {
                prm.product_TypeError = "select an product type";
                prm.Has_Error= true;
            }


          

            if (prm.description.Trim().Length == 0)
            {
                prm.descriptionError= "Enter product description";
                prm.Has_Error = true;
            }

            if (!base.IsUrlValid(prm.product_Link.Trim()) && prm.product_Link.Trim().Length != 0)
            {
                prm.product_LinkError = "Enter valid product link to Jatai website";
                prm.Has_Error = true;
            }
            


          


            return prm.Has_Error;
        }
Exemplo n.º 15
0
        public JsonResult Delete(string codeSLSP, string SalesRepCode, string Territory)
        {


            ProductManifest spm = new ProductManifest();



            //BusinessLogic.SalesPerson.SalesPerson sp = new BusinessLogic.SalesPerson.SalesPerson();
            //DataSet.DSParameter ds = new DataSet.DSParameter();
            //ds.ARSAP.AddARSAPRow(codeSLSP, "", SalesRepCode, Territory, "");
            //if (sp.Delete(ds))
            //{
            //    spm.Has_Error = false;
            //    MvcApplication.RefreshData("", null, System.Web.Caching.CacheItemRemovedReason.DependencyChanged);
            //}
            //else
            //{
            //    spm.Has_Error = true;

            //}

            return this.Json(spm, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 16
0
        public JsonResult Save()
        {


            ProductManifest pm = new ProductManifest();

            // 
            if (!Validate(ref pm))
            {
                BusinessLogic.Product.Product sp = new BusinessLogic.Product.Product();
                DataSet.DSParameter ds = new DataSet.DSParameter();

                ds.Product.Product_IDColumn.ReadOnly = false;
                
                ds.Product.AddProductRow(pm.product, pm.code_To_Display, pm.product_Code, 1, pm.product_Type,
                        1, DateTime.Now, pm.description, pm.is_Active, pm.file_Name, "", "", pm.product_Link);
                ds.EnforceConstraints = false;
                ds.Product[0]["Product_ID"] = Convert.ToInt32( pm.product_ID );

                if (pm.hidState == 3)
                {
                    sp.New(ds);
                }
                else
                {
                    sp.Update(ds);
                }
                UpdateCache();
            }


            return this.Json(pm, JsonRequestBehavior.AllowGet);
        }