public void ServiceThrowsOnRecreateNothing() { var service = new XmlTermsService(String.Empty); try { service.RecreateStorage(null, Scheduler.Immediate); Assert.Fail(); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(ArgumentNullException)); Assert.IsTrue(((ArgumentNullException)ex).ParamName == "terms"); } }
public void ObservableThrowsOnRecreateInvalidTerms() { var service = new XmlTermsService(String.Empty); // Test null. var invalidTerms = new Term[] { XmlTermsServiceFixture.SampleTerms[0], new Term(null, String.Empty), }; Exception ex = null; service .RecreateStorage(invalidTerms, Scheduler.Immediate) .Subscribe(_ => { }, ex2 => ex = ex2, () => { }); Assert.IsInstanceOfType(ex, typeof(InvalidTermsStorageException)); // Test whitespace. invalidTerms = new Term[] { XmlTermsServiceFixture.SampleTerms[0], new Term(" ", String.Empty), }; ex = null; service .RecreateStorage(invalidTerms, Scheduler.Immediate) .Subscribe(_ => { }, ex2 => ex = ex2, () => { }); Assert.IsInstanceOfType(ex, typeof(InvalidTermsStorageException)); }
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); }