public void GetBySlug_ThrowsAnException_WhenTheFile_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(() => "MarkdownFiles"); var fileMarkdownGetter = new FileMarkdownGetter(envMock.Object, configurationMock.Object); Assert.Throws <FileNotFoundException>(() => fileMarkdownGetter.GetBySlug("not-exited-slug")); }
public void GetBySlug_ReturnsContentsOfTheRightFile(string slug, string title) { 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.Contains(title, fileMarkdownGetter.GetBySlug(slug), StringComparison.Ordinal); }