public void ObservableThrowsWhenFileDoesntExist() { var service = new XmlTermsService(String.Empty); ReactiveAssert.Throws <InvalidTermsStorageException>( () => { service .LoadTerms(Scheduler.Immediate) .Subscribe(); }); }
public void ObservableLoadsNoTermsFromEmptyValidXml() { var service = new XmlTermsService(XmlTermsServiceFixture.TermsToFile( Enumerable.Empty <Term>(), "ObservableLoadsNoTermsFromEmptyValidXml.xml")); var serviceTerms = new List <Term>(); service .LoadTerms(Scheduler.Immediate) .Subscribe(terms => serviceTerms.AddRange(terms)); ReactiveAssert.AreElementsEqual(Enumerable.Empty <Term>(), serviceTerms); }
public void ObservableRecreatesNewStorage() { var filePath = Path.Combine(XmlTermsServiceFixture.DeploymentDirectory, "ObservableRecreatesNewStorage.xml"); var service = new XmlTermsService(filePath); service .RecreateStorage(XmlTermsServiceFixture.SampleTerms, Scheduler.Immediate) .Subscribe(); var storedTerms = new List <Term>(); service .LoadTerms(Scheduler.Immediate) .Subscribe(terms => storedTerms.AddRange(terms)); ReactiveAssert.AreElementsEqual(XmlTermsServiceFixture.SampleTerms, storedTerms); }
public void ObservableThrowsFromInvalidXml() { var service = new XmlTermsService(XmlTermsServiceFixture.TermsToFile( new Term[] { XmlTermsServiceFixture.SampleTerms[0], new Term(null, String.Empty), }, "ObservableThrowsFromInvalidXml.xml")); ReactiveAssert.Throws <InvalidTermsStorageException>( () => { service .LoadTerms(Scheduler.Immediate) .Subscribe(); }); }
public void ObservableShouldntPushTermsFromInvalidXml() { var mix = new Term[] { XmlTermsServiceFixture.SampleTerms[0], new Term(null, null), XmlTermsServiceFixture.SampleTerms[1], }; var service = new XmlTermsService( XmlTermsServiceFixture.TermsToFile(mix, "ObservableShouldntPushTermsFromInvalidXml.xml")); bool onNextInvoked = false; service .LoadTerms(Scheduler.Immediate) .Subscribe(terms => onNextInvoked = true, _ => { }, () => { }); Assert.IsFalse(onNextInvoked); }