コード例 #1
0
        public void GetLocationAssetFileAndVersionNoCdnTest()
        {
            var expectedAssetFileLocation = "/ResourcePackages/folder/assets/dist/DummyAssetFile?";

            A.CallTo(() => fakeConfigurationProvider.GetConfig <string>(A <string> ._)).Returns(null);
            A.CallTo(() => fakeWbAppContext.ServerMapPath(A <string> ._)).ReturnsLazily((string file) => file);

            var assetLocationAndVersion = new AssetLocationAndVersion(fakeConfigurationProvider, fakeHTTPClientService, fakeAsyncHelper, fakeWbAppContext, fakeApplicationLogger);
            var result = assetLocationAndVersion.GetLocationAssetFileAndVersion(DummyAssetFilePath);

            result.Should().Be(expectedAssetFileLocation);
        }
 public string GetLocationAssetFileAndVersion(string fileName)
 {
     if (!string.IsNullOrEmpty(CDNLocation))
     {
         var assetLocation = $"{CDNLocation}/{fileName}";
         var version       = asyncHelper.Synchronise(() => GetFileHashAsync(assetLocation));
         return($"{assetLocation}?{version}");
     }
     else
     {
         var assetLocation = $"/ResourcePackages/{fileName.Substring(0, fileName.IndexOf("/"))}/assets/dist/{fileName.Substring(fileName.IndexOf("/") + 1)}";
         var physicalPath  = context.ServerMapPath($"~{assetLocation}");
         var version       = GetFileHash(physicalPath);
         return($"{assetLocation}?{version}");
     }
 }
コード例 #3
0
        public void GetLocationAssetFileAndVersionNoCdnTest()
        {
            var dummyHttpResponseMessage = new HttpResponseMessage()
            {
                Content    = new StringContent("Dummy Content"),
                StatusCode = System.Net.HttpStatusCode.InternalServerError
            };

            var expectedAssetFileLocation = "/ResourcePackages/folder/assets/dist/DummyAssetFile?";

            A.CallTo(() => fakeConfigurationProvider.GetConfig <string>(A <string> ._)).Returns(null);
            A.CallTo(() => fakeWbAppContext.ServerMapPath(A <string> ._)).ReturnsLazily((string file) => file);

            var assetLocationAndVersion = new AssetLocationAndVersion(fakeConfigurationProvider, fakeHTTPClientService, fakeAsyncHelper, fakeWbAppContext, fakeApplicationLogger);
            var result = assetLocationAndVersion.GetLocationAssetFileAndVersion(DummyAssetFilePath);

            result.Should().Be(expectedAssetFileLocation);
        }