Exemplo n.º 1
0
    private async Task <Version> CheckVersionFromGithubAsync()
    {
        _logger.Debug("[{0}] Checking github repository for a new version...", this.GetType().Name);
        const string url = "https://raw.githubusercontent.com/mortuusars/PSQuickAssets/master/PSQuickAssets/PSQuickAssets.csproj";

        try
        {
            string file = await ReadStringFromURL(url);

            return(CsProjVersionParser.Parse(file));
        }
        catch (Exception ex)
        {
            _logger.Error("[{0}] Getting version from '{1}' failed: {2}.", this.GetType().Name, url, ex.Message);
            return(new Version());
        }
    }
 public void GetVersionShouldGetRightVersion()
 {
     Assert.Equal(new Version("1.2.0"), CsProjVersionParser.Parse("asdasdkjwlkj<Version>1.2.0</Version>"));
 }
 public void GetVersionThrowsIfNotFound()
 {
     Assert.Throws <ArgumentException>(() => CsProjVersionParser.Parse("asdasdkjwlkjon"));
 }