public void GivenAFileIsLoaded_WhenTheFileDoesNotExist_ThenAnEmptyEnumerableShouldBeReturned() { const string testFileName = "test.json"; IEnumerable <Feature> actual = null; _fileReader.Setup(x => x.ReadToEnd(testFileName)).Throws <FileNotFoundException>(); var loader = new FileFeatureLoadingStrategy(testFileName, _fileReader.Object); Assert.DoesNotThrow(() => actual = loader.GetFeatures().ToList()); Assert.IsNotNull(actual); }
public void GivenANewInstanceIsCreated_ThenANewInstanceShouldBeReturned() { const string testFileName = "test.json"; _fileReader .Setup(x => x.ReadToEnd(testFileName)) .Returns("{\"test\": 1}"); var loader = new FileFeatureLoadingStrategy(testFileName, _fileReader.Object); Assert.IsNotNull(loader); }
public void GivenAFileIsLoaded_WhenTheFileContainsFeatures_ThenTheCorrectFeaturesShouldBeReturned() { const string testFileName = "test.json"; var expected = new Feature { Enabled = true, Name = "test" }; _fileReader .Setup(x => x.ReadToEnd(testFileName)) .Returns("{\"test\": 1}"); var loader = new FileFeatureLoadingStrategy(testFileName, _fileReader.Object); var actual = loader.GetFeatures().ToList(); Assert.IsNotNull(actual); Assert.IsTrue(actual.Any()); Assert.That(actual.First().Name, Is.EqualTo(expected.Name)); Assert.That(actual.First().Enabled, Is.EqualTo(expected.Enabled)); }