public void GetAll_ReturnsGeneratorOfPostString_WithDescendingOrder() { var envMock = new Mock <IHostEnvironment>(); envMock.Setup(x => x.ContentRootPath) .Returns(() => Path.Combine(Directory.GetCurrentDirectory(), @"Stubs\")); var configurationMock = new Mock <Microsoft.Extensions.Configuration.IConfiguration>(); configurationMock.Setup(x => x[It.IsAny <string>()]) .Returns(() => "MarkdownFiles"); var fileMarkdownGetter = new FileMarkdownGetter(envMock.Object, configurationMock.Object); Assert.Equal(2, fileMarkdownGetter.GetAll().ToList().Count); Assert.Contains("Post 2", fileMarkdownGetter.GetAll().ToList()[0], StringComparison.Ordinal ); Assert.Contains("Post 1", fileMarkdownGetter.GetAll().ToList()[1], StringComparison.Ordinal ); }
public void GetAll_ThrowsAnException_WhenTheDirectory_DoesNotExit() { var envMock = new Mock <IHostEnvironment>(); envMock.Setup(x => x.ContentRootPath) .Returns(() => Path.Combine(Directory.GetCurrentDirectory(), @"Stubs\")); var configurationMock = new Mock <Microsoft.Extensions.Configuration.IConfiguration>(); configurationMock.Setup(x => x[It.IsAny <string>()]) .Returns(() => "NotExistedFolder"); var fileMarkdownGetter = new FileMarkdownGetter(envMock.Object, configurationMock.Object); Assert.Throws <DirectoryNotFoundException>(() => fileMarkdownGetter.GetAll().ToList()); }