|
| 1 | +using Microsoft.Graph.ODataTemplateWriter.CodeHelpers.CSharp; |
| 2 | +using Microsoft.Graph.ODataTemplateWriter.CodeHelpers.TypeScript; |
| 3 | +using Microsoft.Graph.ODataTemplateWriter.CodeHelpers.PHP; |
| 4 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 5 | +using Vipr.Core.CodeModel; |
| 6 | + |
| 7 | + |
| 8 | +namespace GraphODataTemplateWriter.Test |
| 9 | +{ |
| 10 | + [TestClass] |
| 11 | + public class TypeHelperTests |
| 12 | + { |
| 13 | + OdcmProperty testProperty; |
| 14 | + string actualInputString = "\r\n Test string"; |
| 15 | + string expectedOutputString = "\r\n/// Test string"; |
| 16 | + |
| 17 | + [TestInitialize] |
| 18 | + public void Initialize() |
| 19 | + { |
| 20 | + testProperty = new OdcmProperty("testPropertyName"); |
| 21 | + } |
| 22 | + |
| 23 | + /// <summary> |
| 24 | + /// Test that GetSanitizedLongDescription provides long descriptions without uncommented lines of text. |
| 25 | + /// </summary> |
| 26 | + [TestMethod] |
| 27 | + public void Long_Description_Doesnt_Contain_Uncommented_NewLine_For_CSharp() |
| 28 | + { |
| 29 | + testProperty.LongDescription = actualInputString; |
| 30 | + string sanitizedString = TypeHelperCSharp.GetSanitizedLongDescription(testProperty); // Explicitly bind to extension method. |
| 31 | + |
| 32 | + Assert.AreEqual(expectedOutputString, sanitizedString, "GetSanitizedLongDescription is not handling escaped CRLF."); |
| 33 | + } |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// Test that GetSanitizedLongDescription provides descriptions without uncommented lines of text. |
| 37 | + /// </summary> |
| 38 | + [TestMethod] |
| 39 | + public void Description_Doesnt_Contain_Uncommented_NewLine_For_CSharp() |
| 40 | + { |
| 41 | + testProperty.Description = actualInputString; |
| 42 | + string sanitizedString = TypeHelperCSharp.GetSanitizedLongDescription(testProperty); |
| 43 | + |
| 44 | + Assert.AreEqual(expectedOutputString, sanitizedString, "GetSanitizedLongDescription is not handling escaped CRLF."); |
| 45 | + } |
| 46 | + |
| 47 | + /// <summary> |
| 48 | + /// Test that GetSanitizedLongDescription provides long descriptions without uncommented lines of text for Typescript. |
| 49 | + /// </summary> |
| 50 | + [TestMethod] |
| 51 | + public void Long_Description_Doesnt_Contain_Uncommented_NewLine_For_Typescript() |
| 52 | + { |
| 53 | + testProperty.LongDescription = actualInputString; |
| 54 | + string sanitizedString = TypeHelperTypeScript.GetSanitizedLongDescription(testProperty); // Explicitly bind to extension method. |
| 55 | + |
| 56 | + Assert.AreEqual(expectedOutputString, sanitizedString, "GetSanitizedLongDescription is not handling escaped CRLF."); |
| 57 | + } |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Test that GetSanitizedLongDescription provides descriptions without uncommented lines of text for Typescript. |
| 61 | + /// </summary> |
| 62 | + [TestMethod] |
| 63 | + public void Description_Doesnt_Contain_Uncommented_NewLine_For_Typescript() |
| 64 | + { |
| 65 | + testProperty.Description = actualInputString; |
| 66 | + string sanitizedString = TypeHelperTypeScript.GetSanitizedLongDescription(testProperty); |
| 67 | + |
| 68 | + Assert.AreEqual(expectedOutputString, sanitizedString, "GetSanitizedLongDescription is not handling escaped CRLF."); |
| 69 | + } |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// Test that GetSanitizedLongDescription provides long descriptions without uncommented lines of text for PHP. |
| 73 | + /// </summary> |
| 74 | + [TestMethod] |
| 75 | + public void Long_Description_Doesnt_Contain_Uncommented_NewLine_For_PHP() |
| 76 | + { |
| 77 | + testProperty.LongDescription = actualInputString; |
| 78 | + string sanitizedString = TypeHelperPHP.GetSanitizedLongDescription(testProperty); // Explicitly bind to extension method. |
| 79 | + |
| 80 | + Assert.AreEqual(expectedOutputString, sanitizedString, "GetSanitizedLongDescription is not handling escaped CRLF."); |
| 81 | + } |
| 82 | + |
| 83 | + /// <summary> |
| 84 | + /// Test that GetSanitizedLongDescription provides descriptions without uncommented lines of text for PHP. |
| 85 | + /// </summary> |
| 86 | + [TestMethod] |
| 87 | + public void Description_Doesnt_Contain_Uncommented_NewLine_For_PHP() |
| 88 | + { |
| 89 | + testProperty.Description = actualInputString; |
| 90 | + string sanitizedString = TypeHelperPHP.GetSanitizedLongDescription(testProperty); |
| 91 | + |
| 92 | + Assert.AreEqual(expectedOutputString, sanitizedString, "GetSanitizedLongDescription is not handling escaped CRLF."); |
| 93 | + } |
| 94 | + } |
| 95 | +} |
0 commit comments