public void TestComparison()
        {
            VersionIdentifier[] identifiers = new VersionIdentifier[sorted_version_strings.Length];
            int res;

            for (int i = 0; i < identifiers.Length; i++)
            {
                identifiers[i] = new VersionIdentifier(sorted_version_strings[i]);
            }

            for (int i = 0; i < identifiers.Length; i++)
            {
                for (int j = 0; j < identifiers.Length; j++)
                {
                    res = identifiers[i].Compare(identifiers[j]);
                    if (i < j)
                    {
                        Assert.AreEqual(-1, res, "expected {0} < {1}, got {2}", sorted_version_strings[i], sorted_version_strings[j], res);
                    }
                    else if (i == j)
                    {
                        Assert.AreEqual(0, res, "expected {0} = {1}, got {2}", sorted_version_strings[i], sorted_version_strings[j], res);
                    }
                    else
                    {
                        Assert.AreEqual(1, res, "expected {0} > {1}, got {2}", sorted_version_strings[i], sorted_version_strings[j], res);
                    }
                }
            }

            res = new VersionIdentifier("1.0").Compare("1.0.0");
            Assert.AreEqual(0, res, "expected 1.0 = 1.0.0, got {0}", res);
        }
        private void ControlsToData()
        {
            if (_toolDependancy == null)
            {
                if (rbDriver.Checked)
                {
                    _toolDependancy = new HardwareItemDescriptionControlToolDriver();
                }
                else if (rbSoftware.Checked)
                {
                    _toolDependancy = new HardwareItemDescriptionControlToolSoftware();
                }
            }
            else
            {
                if (_toolDependancy is HardwareItemDescriptionControlToolDriver && rbSoftware.Checked)
                {
                    _toolDependancy = new HardwareItemDescriptionControlToolSoftware();
                }
                else if (_toolDependancy is HardwareItemDescriptionControlToolSoftware && rbDriver.Checked)
                {
                    _toolDependancy = new HardwareItemDescriptionControlToolDriver();
                }
            }

            if (_toolDependancy != null)
            {
                _toolDependancy.name      = controlToolDependancyControl1.VersionIdentifier.name;
                _toolDependancy.qualifier = controlToolDependancyControl1.VersionIdentifier.qualifier;
                _toolDependancy.version   = controlToolDependancyControl1.VersionIdentifier.version;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Get the short url for a blob.
        /// </summary>
        /// <param name="feedConfig">Feed configuration</param>
        /// <param name="blob">Blob</param>
        /// <returns>Short url prefix for the blob.</returns>
        /// <remarks>
        public string GetLatestShortUrlForBlob(TargetFeedConfig feedConfig, BlobArtifactModel blob, bool flatten)
        {
            string blobIdWithoutVersions = VersionIdentifier.RemoveVersions(blob.Id);

            if (flatten)
            {
                blobIdWithoutVersions = Path.GetFileName(blobIdWithoutVersions);
            }

            return(Path.Combine(feedConfig.LatestLinkShortUrlPrefix, blobIdWithoutVersions).Replace("\\", "/"));
        }
 virtual protected void ControlsToData()
 {
     if (_versionIdentifier == null)
     {
         _versionIdentifier = new VersionIdentifier();
     }
     _versionIdentifier.version   = edtVersion.GetValue <string>();
     _versionIdentifier.name      = edtVersionName.GetValue <string>();
     _versionIdentifier.qualifier =
         (VersionIdentifierQualifier)
         Enum.Parse(typeof(VersionIdentifierQualifier), (string)cmbVersionIdentifierQualifier.SelectedItem);
 }
Ejemplo n.º 5
0
        public static WebStoreRepoBase GetRepo(VersionIdentifier version)
        {
            var typeName = $"WebStoreDbGenerator.{version}.WebStore{version}Repo";

            try
            {
                var type = Type.GetType(typeName);
                var obj  = Activator.CreateInstance(type);
                return((WebStoreRepoBase)obj);
            }
            catch
            {
                throw new Exception($"Can't create instance of {typeName} for version {version}");
            }
        }
Ejemplo n.º 6
0
        public void ValidateVersions()
        {
            List <VersionIdentifierTestAsset> testAssets = GetTestAssets();

            foreach (VersionIdentifierTestAsset testAsset in testAssets)
            {
                // First check whether the original version number can be identified
                string expectedVersion = testAsset.ExpectedVersion;
                string actualVersion   = VersionIdentifier.GetVersion(testAsset.Name);
                Assert.True(expectedVersion == actualVersion, $"Line {testAsset.Line} has incorrect computed version {actualVersion}");
                // Then check that all versions can be removed from the path of any blob asset
                string expectedNameWithoutVersions = testAsset.NameWithoutVersions;
                string actualNameWithoutVersions   = VersionIdentifier.RemoveVersions(testAsset.Name);
                Assert.True(expectedNameWithoutVersions == actualNameWithoutVersions, $"Line {testAsset.Line} has incorrect asset name without versions {actualNameWithoutVersions}");
            }
        }
        public void TestNormalization()
        {
            foreach (var version_string in sorted_version_strings)
            {
                VersionIdentifier ver = new VersionIdentifier(version_string);
                Assert.IsTrue(ver.is_valid, "version string {0} rejected by parser", version_string);
                Assert.AreEqual(ver.ToString(), version_string, "version string did not normalize to itself");
            }

            int i;

            for (i = 0; i < string_normalizations.Length; i += 2)
            {
                VersionIdentifier ver = new VersionIdentifier(string_normalizations[i]);
                Assert.IsTrue(ver.is_valid, "version string {0} rejected by parser", string_normalizations[i]);
                Assert.AreEqual(ver.ToString(), string_normalizations[i + 1], "expected {0} to normalize to {1}", string_normalizations[i], string_normalizations[i + 1]);
            }
        }
        void VersionIdentifierControl_Validating(object sender, CancelEventArgs e)
        {
            string saved = null;

            if (_versionIdentifier != null)
            {
                saved = XmlUtils.SerializeObject(_versionIdentifier);
            }
            ControlsToData();
            ValidateToSchema(_versionIdentifier);
            if (saved == null)
            {
                _versionIdentifier = null;
            }
            else
            {
                _versionIdentifier = (VersionIdentifier)XmlUtils.DeserializeObject(_versionIdentifier, saved);
            }
        }
        public void TestPrefix()
        {
            VersionIdentifier v = new VersionIdentifier("1.0");

            Assert.IsTrue(v.IsPrefix("1.0.0"));
            Assert.IsTrue(v.IsPrefix("1.0.1"));
            Assert.IsTrue(v.IsPrefix("1.0a2"));
            Assert.IsTrue(v.IsPrefix("1"));
            Assert.IsFalse(v.IsPrefix("1.1"));
            Assert.IsFalse(v.IsPrefix("2:1.0"));
            Assert.IsFalse(v.IsPrefix("2.0"));

            v = new VersionIdentifier("1.0.1");

            Assert.IsTrue(v.IsPrefix("1.0.1"));
            Assert.IsTrue(v.IsPrefix("1.0.1post2"));
            Assert.IsTrue(v.IsPrefix("1.0.1dev2"));
            Assert.IsFalse(v.IsPrefix("1.0"));
        }
Ejemplo n.º 10
0
        public void ToDelimitedString_WithAllProperties_ReturnsCorrectlySequencedFields()
        {
            IType hl7Type = new VersionIdentifier
            {
                VersionId = "1",
                InternationalizationCode = new CodedWithExceptions
                {
                    Identifier = "2"
                },
                InternationalVersionId = new CodedWithExceptions
                {
                    Identifier = "3"
                }
            };

            string expected = "1^2^3";
            string actual   = hl7Type.ToDelimitedString();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 11
0
        public async Task <string> Start(TargetOptions targetOptions)
        {
            try
            {
                if ((await InitClientAsync(targetOptions)).IsSuccessStatusCode ||
                    (await InitClientAsync(targetOptions)).StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    ResponseHeaders.PrintResponseHeaders(await InitClientAsync(targetOptions));
                    await RobotsSitemap.GetSitemaps(targetOptions, client);

                    await VersionIdentifier.TryToDetectVersion(targetOptions, client);

                    if (targetOptions.MageReport)
                    {
                        await MageReport.TestMegaReportAsync(targetOptions, client);
                    }

                    if (targetOptions.DiscoverContent)
                    {
                        await DiscoverContent.StartDiscoveryAsync(targetOptions, client);
                    }
                }
                else
                {
                    Logger.Log(Importance.Critical, string.Concat(targetOptions.Url) + " responded " + (await InitClientAsync(targetOptions)).StatusCode, ConsoleColor.Red);
                }
                Logger.Log(Importance.Log, " DONE, press any key to exit.", ConsoleColor.White);
                Console.ReadKey();
                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                Logger.Log(Importance.Critical, "Something went wrong: " + ex.Message, ConsoleColor.Red);
                Logger.Log(Importance.Critical, ex.Source + "\n" + ex.StackTrace, ConsoleColor.Red);
                Console.ReadKey();
                Environment.Exit(0);
            }
            return(null);
        }
Ejemplo n.º 12
0
        public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFields()
        {
            IType expected = new VersionIdentifier
            {
                VersionId = "1",
                InternationalizationCode = new CodedWithExceptions
                {
                    IsSubcomponent = true,
                    Identifier     = "2"
                },
                InternationalVersionId = new CodedWithExceptions
                {
                    IsSubcomponent = true,
                    Identifier     = "3"
                }
            };

            IType actual = new VersionIdentifier();

            actual.FromDelimitedString("1^2^3");

            expected.Should().BeEquivalentTo(actual);
        }
Ejemplo n.º 13
0
        public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (Identifier != null)
            {
                result.AddRange(Identifier.Validate());
            }
            if (VersionIdentifier != null)
            {
                result.AddRange(VersionIdentifier.Validate());
            }
            if (CreatedElement != null)
            {
                result.AddRange(CreatedElement.Validate());
            }
            if (Type != null)
            {
                result.AddRange(Type.Validate());
            }
            if (Subtype != null)
            {
                result.AddRange(Subtype.Validate());
            }
            if (TitleElement != null)
            {
                result.AddRange(TitleElement.Validate());
            }
            if (StatusElement != null)
            {
                result.AddRange(StatusElement.Validate());
            }
            if (Confidentiality != null)
            {
                result.AddRange(Confidentiality.Validate());
            }
            if (Subject != null)
            {
                result.AddRange(Subject.Validate());
            }
            if (Author != null)
            {
                Author.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Attester != null)
            {
                Attester.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Custodian != null)
            {
                result.AddRange(Custodian.Validate());
            }
            if (Event != null)
            {
                result.AddRange(Event.Validate());
            }
            if (Encounter != null)
            {
                result.AddRange(Encounter.Validate());
            }
            if (ReplacesElement != null)
            {
                result.AddRange(ReplacesElement.Validate());
            }
            if (Provenance != null)
            {
                Provenance.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Stylesheet != null)
            {
                result.AddRange(Stylesheet.Validate());
            }
            if (Representation != null)
            {
                result.AddRange(Representation.Validate());
            }
            if (Section != null)
            {
                Section.ForEach(elem => result.AddRange(elem.Validate()));
            }

            return(result);
        }
Ejemplo n.º 14
0
 public void ValidateSimpleVersions(string assetName, string version)
 {
     Assert.Equal(version, VersionIdentifier.GetVersion(assetName));
 }
Ejemplo n.º 15
0
 public void ValidateSimpleVersions(string assetName, string version)
 {
     VersionIdentifier.GetVersion(assetName).Should().Be(version);
 }
Ejemplo n.º 16
0
    public override bool Run(string[] args)
    {
        Console.WriteLine("");
        Console.WriteLine("Identifying version by checking NuGet feed and git origin repository...");
        Console.WriteLine("");

        var packageName = ProjectName;

        if (!CurrentNode.Properties.ContainsKey("NuGetFeedPath"))
        {
            throw new Exception("*.node file doesn't contain 'NuGetFeedPath' property.");
        }

        var sourcePath = CurrentNode.Properties["NuGetFeedPath"];

        Console.WriteLine("Feed source path:");
        Console.WriteLine(sourcePath);
        Console.WriteLine("");

        var commit = Arguments.ContainsAny("c", "commit");

        var status = "";

        if (CurrentNode.Properties.ContainsKey("Status"))
        {
            status = CurrentNode.Properties["Status"];
        }

        var branch = "";

        if (CurrentNode.Properties.ContainsKey("Branch"))
        {
            branch = CurrentNode.Properties["Branch"];
        }

        var identifier = new VersionIdentifier(branch, status, sourcePath, packageName);


        var force = Arguments.ContainsAny("f", "force");

        Console.WriteLine("Status: " + (!String.IsNullOrEmpty(status) ? status : "[Not specified]"));
        Console.WriteLine("");

        var currentVersionString = "0.0.0.0";

        if (CurrentNode.Properties.ContainsKey("Version"))
        {
            currentVersionString = CurrentNode.Properties["Version"];
        }

        if (!String.IsNullOrEmpty(status))
        {
            currentVersionString += "-" + status;
        }

        var currentVersion = new SemanticVersion(currentVersionString);

        var publishedVersion = identifier.GetVersion();

        Console.WriteLine("");
        Console.WriteLine("Current local version: " + currentVersion);
        Console.WriteLine("Latest found version: " + publishedVersion);
        Console.WriteLine("");

        bool changedVersion = false;

        if (publishedVersion != currentVersion)
        {
            if (force ||
                publishedVersion > currentVersion)
            {
                if (force)
                {
                    Console.WriteLine("Current local version is newer. Overwriting anyway.");
                }
                else
                {
                    Console.WriteLine("Latest found version is newer.");
                }

                Console.WriteLine("Using latest found version.");

                ExecuteScript("SetVersion", publishedVersion.Version.ToString());

                changedVersion = true;
            }
            else
            {
                Console.WriteLine("Current local version is newer. Keeping.");
            }
        }
        else
        {
            Console.WriteLine("Current version already matches the published version. Nothing needs to be done.");
        }

        Console.WriteLine("");

        RefreshCurrentNode();

        if (commit && changedVersion)
        {
            ExecuteScript("CommitVersion");
        }

        return(!IsError);
    }
Ejemplo n.º 17
0
 internal override string GetVersion(string assetName)
 {
     return(VersionIdentifier.GetVersion(assetName));
 }
Ejemplo n.º 18
0
 internal override string RemoveVersions(string assetName)
 {
     return(VersionIdentifier.RemoveVersions(assetName));
 }
Ejemplo n.º 19
0
 public override int GetHashCode()
 {
     return(VersionIdentifier.GetHashCode());
 }