コード例 #1
0
        public static void Search_Throws(string packageName)
        {
            var x = new NuGetTool();

            Assert.That(x, Is.Not.Null);

            Assert.That(() => x.Search(packageName), Throws.TypeOf <ArgumentException>());
        }
コード例 #2
0
        public static void Search_InternalRepo_ReturnsExpectedResult(string packageName, bool shouldBeFound)
        {
            var username = AuthenticationHelper.GetUsername();

            var pat = AuthenticationHelper.GetPersonalAccessToken();

            // todo Is there a new URI for this with dev.azure.com?
            var nuGetTool = new NuGetTool(
                "https://upmcappsvcs.pkgs.visualstudio.com/_packaging/services-common/nuget/v3/index.json",
                true,
                username,
                pat
                );

            Assert.That(nuGetTool, Is.Not.Null);

            var result = nuGetTool.Search(packageName);

            // ReSharper disable PossibleMultipleEnumeration
            Assert.That(result, Is.Not.Null);

            if (shouldBeFound)
            {
                // todo Check that multiple results were returned.
                Assert.That(result.Count(), Is.GreaterThan(2));
            }

            var firstSearchResult = result.FirstOrDefault();

            // ReSharper restore PossibleMultipleEnumeration

            if (shouldBeFound)
            {
                Assert.That(firstSearchResult, Is.Not.Null);
                Console.WriteLine(
                    $"Found ID: {firstSearchResult.Identity.Id} Version: {firstSearchResult.Identity.Version}");

                try
                {
                    Console.WriteLine(firstSearchResult.DumpValues(0));
                }
                catch (ArgumentOutOfRangeException exception)
                {
                    Console.WriteLine(exception);
                    // there is a loop somewhere in this object.
                }
            }
            else
            {
                Assert.That(firstSearchResult, Is.Null);
            }
        }
コード例 #3
0
        public static void Search_NuGetOrg_ReturnsExpectedResult(string packageName, bool exactMatch,
                                                                 bool expectedResult)
        {
            var tool = new NuGetTool();

            Assert.That(tool, Is.Not.Null);

            var result = tool.Search(packageName, exactMatch: exactMatch);

            Assert.That(result, Is.Not.Null);

            foreach (var item in result)
            {
                Console.WriteLine($"ID: {item.Identity.Id} Version: {item.Identity.Version}");
            }

            if (expectedResult)
            {
                Assert.That(result.Count(), Is.GreaterThan(0));
            }
            else
            {
                Assert.That(result.Count(), Is.EqualTo(0));
            }

            try
            {
                var myHandlers = new VariableDumpHandlers();
                Console.WriteLine(result.DumpValues(0, handlers: myHandlers));
            }
            catch (ArgumentOutOfRangeException exception)
            {
                Console.WriteLine(exception);
                // there is a loop somewhere in this object.
            }
        }