Example #1
0
        public void NugetHelperSettings_AddSource_NoFeedUrl()
        {
            var feedName = "testfeed";

            var context       = this.GetMoqContext(new Dictionary <string, bool>(), new Dictionary <string, string>());
            var helperSetting = new NugetHelperSettings();

            Assert.ThrowsException <ArgumentNullException>(() => helperSetting.AddSource(feedName, string.Empty));
        }
Example #2
0
        public void NugetHelperSettings_Default()
        {
            var feedName      = NugetHelperSettings.DefaultNugetFeedName;
            var feedUrl       = NugetHelperSettings.DefaultNugetFeedUrl;
            var context       = this.GetMoqContext(new Dictionary <string, bool>(), new Dictionary <string, string>());
            var helperSetting = new NugetHelperSettings();

            Assert.IsNotNull(helperSetting.NugetSources);
            Assert.AreEqual(1, helperSetting.NugetSources.Count());
            Assert.IsTrue(helperSetting.NugetSources.All(t => t.FeedName == feedName && t.FeedSource == feedUrl));
        }
Example #3
0
        public void NugetHelperSettings_AddSource_FeedUrlOnly()
        {
            var feedUrl       = "testfeed";
            var context       = this.GetMoqContext(new Dictionary <string, bool>(), new Dictionary <string, string>());
            var helperSetting = new NugetHelperSettings();

            var firstSource = helperSetting.AddSource(feedUrl);

            Assert.IsNotNull(firstSource);
            Assert.IsFalse(firstSource.IsSecure);
            Assert.IsTrue(string.IsNullOrWhiteSpace(firstSource.FeedName));
            Assert.AreEqual(feedUrl, firstSource.FeedSource);
        }
Example #4
0
        public void NugetHelperSettings_AddSource_ExistingFeed()
        {
            var feedName      = "testfeed";
            var feedUrl       = "testfeed";
            var user          = "******";
            var pass          = "******";
            var context       = this.GetMoqContext(new Dictionary <string, bool>(), new Dictionary <string, string>());
            var helperSetting = new NugetHelperSettings();

            var firstSource = helperSetting.AddSource(feedName, feedUrl);

            Assert.IsNotNull(firstSource);
            Assert.IsFalse(firstSource.IsSecure);

            var nextSource = helperSetting.AddSource(feedName, feedUrl, source =>
            {
                source.IsSecure = true;
                source.Username = user;
                source.Password = pass;
            });

            Assert.IsNotNull(nextSource);
            Assert.AreEqual(firstSource, nextSource);
            Assert.IsTrue(nextSource.IsSecure);
            Assert.AreEqual(feedName, nextSource.FeedName);
            Assert.AreEqual(feedUrl, nextSource.FeedSource);
            Assert.AreEqual(user, nextSource.Username);
            Assert.AreEqual(pass, nextSource.Password);

            var feedUrls = helperSetting.GetFeedUrls();

            Assert.IsNotNull(feedUrls);
            var enumerable = feedUrls as string[] ?? feedUrls.ToArray();

            Assert.AreEqual(2, enumerable.Count());
            Assert.IsTrue(enumerable.Any(t => t == feedUrl));
        }