Exemplo n.º 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));
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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));
        }