예제 #1
0
 public void TestConstructWithValidApiVersion()
 {
     try
     {
         var v1 = new NuGetApi((NuGetApi.Version) 1);
         var v2 = new NuGetApi((NuGetApi.Version) 2);
         var v3 = new NuGetApi((NuGetApi.Version) 3);
         Assert.IsTrue(true);
     }
     catch (Exception)
     {
         Assert.IsTrue(false);
     }
 }
예제 #2
0
 public void TestConstructWithInvalidApiVersion()
 {
     var exceptionsThrown = 0;
     for (int i = 0; i < 5; i++)
     {
         try
         {
             var v = new NuGetApi((NuGetApi.Version) i);
         }
         catch (Exception)
         {
             exceptionsThrown += 1;
         }
     }
     Assert.AreEqual(exceptionsThrown, 2);
 }
예제 #3
0
 public NuGetApi(NuGetApi.Version version)
 {
     switch (version)
     {
         case NuGetApi.Version.V1:
             _url = "https://www.nuget.org/api/v1/";
             break;
         case NuGetApi.Version.V2:
             _url = "https://www.nuget.org/api/v2/";
             break;
         case NuGetApi.Version.V3:
             _url = "https://www.nuget.org/api/v2/";
             break;
         default:
             throw new Exception("Invalid API version " + version.ToString());
     }
 }