public void Initialisation()
        {
            p1 = new VPackage("source", new Version());
            VPackage p2 = new VPackage("conflict1", new Version());
            VPackage p3 = new VPackage("conflict1", new Version());
            VPackage p4 = new VPackage("conflict2", new Version());
            VPackage p5 = new VPackage("conflict2", new Version());
            VPackage p6 = new VPackage("p6", new Version());

            p2.Dependencies = new Dictionary <string, IEnumerable <VPackage> >();
            List <VPackage> d2 = new List <VPackage>();

            d2.Add(p4);
            p1.Dependencies.Add("f2", d2);

            p3.Dependencies = new Dictionary <string, IEnumerable <VPackage> >();
            List <VPackage> d3 = new List <VPackage>();

            d3.Add(p5);
            d3.Add(p6);
            p1.Dependencies.Add("f3", d3);

            p1.Dependencies = new Dictionary <string, IEnumerable <VPackage> >();
            List <VPackage> d1 = new List <VPackage>();

            d3.Add(p2);
            d3.Add(p3);
            p1.Dependencies.Add("f1", d3);
        }
        public void GetDependenciesSpecificVersion(VPackage vPackage)
        {
            List <IPackage> packages = _repo.FindPackagesById(vPackage.PackageId).ToList();

            IEnumerable <IPackage> temp = packages.Where(p => p.IsLatestVersion);
            string lastV = !temp.IsEmpty() ? temp.First().Version.ToString() : String.Empty;

            packages = packages.Where(p => (p.Version.Version.ToString() == vPackage.Version.ToString())).ToList();

            if (!packages.IsEmpty())
            {
                vPackage.LastVersion = lastV;
                Dictionary <string, IEnumerable <VPackage> > dicFrameDep = new Dictionary <string, IEnumerable <VPackage> >();
                foreach (FrameworkName frameW in packages.First().GetSupportedFrameworks())
                {
                    List <VPackage> listdep = new List <VPackage>();
                    foreach (var item in packages.First().GetCompatiblePackageDependencies(frameW))
                    {
                        VPackage vpackagedep = new VPackage(item.Id, item.VersionSpec.MinVersion.Version);
                        listdep.Add(vpackagedep);

                        Console.WriteLine(item.Id);
                        GetDependenciesSpecificVersion(vpackagedep);
                    }
                    dicFrameDep.Add(frameW.FullName, listdep);
                }
                vPackage.Dependencies = dicFrameDep;
            }
        }
Exemple #3
0
        public void Test_JsonSerializer()
        {
            JsonSerializerPackage s = new JsonSerializerPackage();
            NuGetDownloader       n = new NuGetDownloader();
            VPackage vp             = n.FillVPackage("Newtonsoft.Json", n.GetLatestVersionPackage("Newtonsoft.Json"));
            string   result         = s.JsonSerializer(vp);

            JObject rss = JObject.Parse(result);

            Console.WriteLine(rss);
            Assert.Pass();
        }
        public string FillFullDependencies(VPackageEntity vpe)
        {
            VPackage vP = FillVPackage(vpe.PartitionKey, vpe.RowKey);
            Dictionary <string, object> graphInfo = _graphData.ConvertGraphData(vP);

            var ConflictDictionnary = (List <Dictionary <string, object> >)graphInfo["versionConflict"];
            var UpdateDictionnary   = (List <Dictionary <string, string> >)graphInfo["toUpdate"];

            if (!ConflictDictionnary.IsEmpty())
            {
                vpe.StatOfDependencies = "Issue";
            }
            else if (!((List <Dictionary <string, string> >)graphInfo["toUpdate"]).IsEmpty())
            {
                vpe.StatOfDependencies = "Alert";
            }
            else
            {
                vpe.StatOfDependencies = "Ok";
            }

            return(_jsonSeria.JsonSerializer(graphInfo));
        }
        public void Test_ConflictVersion()
        {
            p1 = new VPackage("source", new Version());
            VPackage p2 = new VPackage("conflict1", new Version());
            VPackage p3 = new VPackage("conflict1", new Version());
            VPackage p4 = new VPackage("conflict2", new Version());
            VPackage p5 = new VPackage("conflict2", new Version());
            VPackage p6 = new VPackage("p6", new Version());

            p2.Dependencies = new Dictionary <string, IEnumerable <VPackage> >();
            List <VPackage> d2 = new List <VPackage>();

            d2.Add(p4);
            p1.Dependencies.Add("f2", d2);

            p3.Dependencies = new Dictionary <string, IEnumerable <VPackage> >();
            List <VPackage> d3 = new List <VPackage>();

            d3.Add(p5);
            d3.Add(p6);
            p1.Dependencies.Add("f3", d3);

            p1.Dependencies = new Dictionary <string, IEnumerable <VPackage> >();
            List <VPackage> d1 = new List <VPackage>();

            d3.Add(p2);
            d3.Add(p3);
            p1.Dependencies.Add("f1", d3);

            GraphData gd = new GraphData();

            gd.ConvertGraphData(p1);
            Dictionary <string, List <Dictionary <string, string> > > graph = gd.Graph;

            Console.WriteLine(graph);
        }
        public VPackage FillVPackage(string packageId, string version)
        {
            List <IPackage> packages = _repo.FindPackagesById(packageId).ToList();

            packages = packages.Where(item => (item.Version.ToString() == version)).ToList();

            VPackage vp       = new VPackage(packageId, packages.First().Version.Version);
            string   dateTime = packages.First().Published.ToString();

            dateTime = dateTime.Remove(10);
            string[] dateTimeSplit = dateTime.Split('/');
            if (dateTimeSplit.Length >= 2)
            {
                string temp = dateTimeSplit[1];
                dateTimeSplit[1] = dateTimeSplit[0];
                dateTimeSplit[0] = temp;
                dateTime         = string.Join("/", dateTimeSplit);
            }

            vp.PublicationDate = dateTime;
            GetDependenciesSpecificVersion(vp);

            return(vp);
        }