public void IfSourceReturnsTheUrlOfTheCurrentSource()
 {
     var sourceService = new SourceService();
     Source source = null;
     sourceService.CurrentSourceChanged += x => source = x;
     Assert.AreEqual("http://chocolatey.org/api/feeds", sourceService.Source);
 }
 public void IfSourcesHave2ElementsWhenInstantiated()
 {
     var sourceService = new SourceService();
     IList<Source> sources = null;
     sourceService.SourcesChanged += x => sources = x;
     sourceService.Initialize();
     Assert.AreEqual(2,sources.Count);
 }
 public void IfSourcesAreLoadedWhenInstantiated()
 {
     var sourceService = new SourceService();
     IList<Source> sources = null;
     sourceService.SourcesChanged += x => sources = x;
     sourceService.Initialize();
     Assert.IsNotNull(sources);
 }
 public void IfCurrentSourceIsTheFirstSourceWhenInstantiated()
 {
     var sourceService = new SourceService();
     Source source = null;
     sourceService.CurrentSourceChanged += x => source = x;
     sourceService.Initialize();
     Assert.AreEqual("Chocolatey.org",source.Name);
 }
 public void IfCurrentSourceIsNotEmptyWhenInstantiated()
 {
     var sourceService = new SourceService();
     Source source = null;
     sourceService.CurrentSourceChanged += x => source = x;
     sourceService.Initialize();
     Assert.IsNotNull(source);
 }
        public void IfSourceReturnsTheUrlOfTheCurrentSource()
        {
            string expectedUrl = "http://first.url.com/notSureIunderstandThisTest?";
            var sourceService = new SourceService(GetMockFileStorageWithSources(firstUrl: expectedUrl, secondUrl: "http://totally.different.com"));
            Source source = null;
            sourceService.CurrentSourceChanged += x => source = x;

            sourceService.Initialize();

            Assert.AreEqual(expectedUrl, sourceService.Source);
        }
        public void IfSetCurrentSourceWithRealFileSystemSetsTheSourceToFirstEntryInFile()
        {
            var sourceService = new SourceService();
            var firstEntry = XDocument.Load("sources.xml").Descendants().First(d => d.Name.LocalName == "name").Value;	// yeah, this totally won't be the first thing to break :P
            Source source = null;
            sourceService.CurrentSourceChanged += x => source = x;

            sourceService.Initialize();

            Assert.AreEqual(firstEntry, source.Name);
        }
        public void IfSetCurrentSourceSetsTheCurrentsource()
        {
            var newService = new Source() { Name = "Third Service", Url = "http://third.entry.com"};
            var sourceService = new SourceService(GetMockFileStorageWithSources());
            Source source = null;
            sourceService.CurrentSourceChanged += x => source = x;

            sourceService.SetCurrentSource(newService);

            Assert.AreEqual(newService.Url, sourceService.Source);
        }
        public void IfCurrentSourceIsTheFirstSourceWhenInstantiated()
        {
            string expectedFirstName = "First Entry";
            var sourceService = new SourceService(GetMockFileStorageWithSources(firstName: expectedFirstName, secondName: "SECOND!1One!1"));
            Source source = null;
            sourceService.CurrentSourceChanged += x => source = x;

            sourceService.Initialize();

            Assert.AreEqual(expectedFirstName, source.Name);
        }