public void IfSourcesAreLoadedWhenInstantiated()
 {
     var sourceService = new SourceService(GetMockFileStorageWithSources());
     IList<Source> sources = null;
     sourceService.SourcesChanged += x => sources = x;
     sourceService.Initialize();
     Assert.IsNotNull(sources);
 }
 public void IfCurrentSourceIsNotEmptyWhenInstantiated()
 {
     var sourceService = new SourceService(GetMockFileStorageWithSources());
     Source source = null;
     sourceService.CurrentSourceChanged += x => source = x;
     sourceService.Initialize();
     Assert.IsNotNull(source);
 }
        public void IfSourceReturnsTheUrlOfTheCurrentSource()
        {
            const string expectedUrl = "http://first.url.com/notSureIunderstandThisTest?";
            var sourceService = new SourceService(GetMockFileStorageWithSources(firstUrl: expectedUrl, secondUrl: "http://totally.different.com"));

            sourceService.Initialize();

            Assert.AreEqual(expectedUrl, sourceService.Source.Url);
        }
        public void IfSetCurrentSourceSetsTheCurrentsource()
        {
            var newService = new Source { Name = "Third Service", Url = "http://third.entry.com"};
            var sourceService = new SourceService(GetMockFileStorageWithSources());

            sourceService.SetCurrentSource(newService);

            Assert.AreEqual(newService, sourceService.Source);
        }
        public void IfSetCurrentSourceWithRealFileSystemSetsTheSourceToFirstEntryInFile()
        {
            var sourceService = new SourceService(new LocalFileSystemStorageService());
            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 IfCurrentSourceIsTheFirstSourceWhenInstantiated()
        {
            const string expectedFirstName = "First Entry";
            var sourceService = new SourceService(GetMockFileStorageWithSources(expectedFirstName, secondName: "SECOND!1One!1"));
            Source source = null;
            sourceService.CurrentSourceChanged += x => source = x;

            sourceService.Initialize();

            Assert.AreEqual(expectedFirstName, source.Name);
        }
 public void IfSourcesHave2ElementsWhenInstantiated()
 {
     var sourceService = new SourceService(GetMockFileStorageWithSources());
     IList<Source> sources = null;
     sourceService.SourcesChanged += x => sources = x;
     sourceService.Initialize();
     Assert.AreEqual(2,sources.Count);
 }