public SharePointGroup() { AddApiCallHandler = async(keyValuePairs) => { return(await Task.Run(() => { var endPointUri = $"_api/web/sitegroups"; var body = new { __metadata = new { type = "SP.Group" }, Title, }; var jsonBody = JsonSerializer.Serialize(body); return new ApiCall(endPointUri, ApiType.SPORest, jsonBody); }).ConfigureAwait(false)); }; ValidateUpdateHandler = (PropertyUpdateRequest propertyUpdateRequest) => { if (propertyUpdateRequest.PropertyName == nameof(Description)) { propertyUpdateRequest.Value = HtmlToText.ConvertSimpleHtmlToText(propertyUpdateRequest.Value.ToString(), 511); } }; }
public void SimpleText() { string input = "this is not html"; string expected = "this is not html"; var result = HtmlToText.ConvertSimpleHtmlToText(input, 1000); Assert.AreEqual(expected, result); }
public void SpecialCharHtml() { string input = "<meta name=\"analytics-location\" content=\"/<user-name>/<repo-name>\" data-pjax-transient=\"true\">This " " & ' < >   is text</meta>"; string expected = "This \" \" & ' < > is text"; var result = HtmlToText.ConvertSimpleHtmlToText(input, 1000); Assert.AreEqual(expected, result); }
public void SimpleHtml() { string input = "this <B>is</B> not <Span><Span>html</Span></span>"; string expected = "this is not html"; var result = HtmlToText.ConvertSimpleHtmlToText(input, 1000); Assert.AreEqual(expected, result); }
public void ComplexHtmlWithLengtLimit() { string input = "<title>GitHub - pnp/pnpcore: The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called</title><meta name=\"description\" content=\"The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called - GitHub - pnp/pnpcore: The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called\"><link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"/opensearch.xml\" title=\"GitHub\"><link rel=\"fluid-icon\" href=\"https://github.com/fluidicon.png\" title=\"GitHub\">"; string expected = "GitHub - pnp/pnpcore: The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with Sha"; var result = HtmlToText.ConvertSimpleHtmlToText(input, 151); Assert.AreEqual(expected, result); Assert.IsTrue(expected.Length == 151); }