public void GetLocalAssetFileAndVersionReturnsLocationWhenFileDoesNotExist() { var assetLocationAndVersionService = new AssetLocationAndVersionService(defaultHttpClient, asyncHelper, webHostEnvironment, logger, fileInfoHelper); var result = assetLocationAndVersionService.GetLocalAssetFileAndVersion(TestLocalLocation); Assert.Equal($"/{TestLocalLocation}?", result); }
public void GetLocalAssetFileAndVersionReturnsLocationWhenFileDoesExist() { var fakeStream = new MemoryStream(Encoding.UTF8.GetBytes("SomeTestData")); var fakeMD5 = MD5.Create(); var expectedHashCode = BitConverter.ToString(fakeMD5.ComputeHash(fakeStream)).Replace("-", string.Empty, StringComparison.OrdinalIgnoreCase); fakeStream.Position = 0; var fileExists = A.Fake <IFileInfoHelper>(); A.CallTo(() => fileExists.FileExists(A <string> .Ignored)).Returns(true); A.CallTo(() => fileExists.GetStream(A <string> .Ignored)).Returns(fakeStream); var assetLocationAndVersionService = new AssetLocationAndVersionService(defaultHttpClient, asyncHelper, webHostEnvironment, logger, fileExists); var result = assetLocationAndVersionService.GetLocalAssetFileAndVersion(TestLocalLocation); Assert.Equal($"/{TestLocalLocation}?{expectedHashCode}", result); fakeStream.Dispose(); fakeMD5.Dispose(); }