public async Task TestGetImageAsyncInvalidFileNames(string filename) { var ctl = new AssetsController( _loggerMock.Object, _appSettingsMock.Object, _imageStorageSettingsMock.Object, _asyncImageStorageProviderMock.Object, _blogConfigMock.Object, _siteIconGeneratorMock.Object); var memCacheMock = new Mock <IMemoryCache>(); var result = await ctl.GetImageAsync(filename, memCacheMock.Object); Assert.IsInstanceOf(typeof(BadRequestObjectResult), result); }
public async Task TestGetImageAsyncCDN() { const string filename = "test.png"; var ctl = new AssetsController( _loggerMock.Object, _appSettingsMock.Object, _imageStorageSettingsMock.Object, _asyncImageStorageProviderMock.Object, _blogConfigMock.Object, _siteIconGeneratorMock.Object); var memCacheMock = new Mock <IMemoryCache>(); var result = await ctl.GetImageAsync(filename, memCacheMock.Object); Assert.IsInstanceOf(typeof(RedirectResult), result); if (result is RedirectResult rdResult) { var resultUrl = Utils.CombineUrl(_imageStorageSettingsMock.Object.Value.CDNSettings.CDNEndpoint, filename); Assert.That(rdResult.Url, Is.EqualTo(resultUrl)); } }