public void GetEndpointForFileExtension_ReturnsCorrectEndpointForBothKnownAndUnknownFileExtensions() { var logger = new Moq.Mock <ILogger>().Object; var sourceEndpoint = new Uri(WOPI_ROOT + "client/hosting/discovery", UriKind.Absolute); var xml = XDocument.Parse(WOPI_DISCOVERY_DOCUMENT_XML, LoadOptions.None); IWopiDiscoveryDocument wopiDiscoveryDocument = new WopiDiscoveryDocument(sourceEndpoint, xml, logger); var endpoint = wopiDiscoveryDocument.GetEndpointForFileExtension("docx", "edit", new Uri(WOPI_FILE_SRC, UriKind.Absolute)); Assert.IsNotNull(endpoint, "Expected the endpoint to be returned when it is supported by the wopi client"); Assert.IsTrue(endpoint.IsAbsoluteUri, "The endpoint should be an absolute uri for supported file extensions"); endpoint = wopiDiscoveryDocument.GetEndpointForFileExtension("fakefileextension", "edit", new Uri(WOPI_FILE_SRC, UriKind.Absolute)); Assert.IsNull(endpoint, "Expected a null return value when the file extension is not supported by the wopi client"); }
public void TransformActionUrlSrcAttribute_CorrectlyReplacesAndRemovesPlaceholders(string urlSrc, string wopiSrc, string expectedUrlSrc) { var transformedUrlSrc = WopiDiscoveryDocument.TransformActionUrlSrcAttribute(urlSrc, new Uri(wopiSrc, UriKind.Absolute)); Assert.AreEqual(expectedUrlSrc, transformedUrlSrc); }