Skip to content

Commit a606eff

Browse files
authored
Removed whitespace being generated by Inflector library on namespaces (#234)
* Removed whitespace being generated by Inflector library when using the Titleize method on namespaces with multiple capitals, such as 'Microsoft.OfficeService' becoming 'Microsoft.Office Service' * fix issue with test breaking build
1 parent 1330e93 commit a606eff

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

GraphODataTemplateWriter.Test/TypeHelperTests.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,25 @@ public void Description_Doesnt_Contain_Uncommented_NewLine_For_PHP()
9191

9292
Assert.AreEqual(expectedOutputString, sanitizedString, "GetSanitizedLongDescription is not handling escaped CRLF.");
9393
}
94-
}
94+
95+
[TestMethod]
96+
public void Namespace_Shouldnt_Contain_Whitespace_For_CSharp()
97+
{
98+
var testNamespace = new OdcmNamespace("Microsoft.OutlookServices");
99+
100+
var namespaceName = TypeHelperCSharp.GetNamespaceName(testNamespace);
101+
102+
Assert.AreEqual(namespaceName, "Microsoft.OutlookServices");
103+
}
104+
105+
[TestMethod]
106+
public void Namespace_Should_PascalCase_For_CSharp()
107+
{
108+
var testNamespace = new OdcmNamespace("microsoft.graph");
109+
110+
var namespaceName = TypeHelperCSharp.GetNamespaceName(testNamespace);
111+
112+
Assert.AreEqual(namespaceName, "Microsoft.Graph");
113+
}
114+
}
95115
}

src/GraphODataTemplateWriter/CodeHelpers/CSharp/TypeHelperCSharp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public static bool IsComplex(this string t)
203203

204204
public static string GetNamespaceName(this OdcmNamespace namespaceObject)
205205
{
206-
return Inflector.Inflector.Titleize(namespaceObject.Name);
206+
return Inflector.Inflector.Titleize(namespaceObject.Name).Replace(" ", "");
207207
}
208208

209209
public static string GetToLowerFirstCharName(this OdcmProperty property)

test/Typewriter.Test/Given_a_valid_metadata_file_to_Typewriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public void It_transforms_metadata()
478478
{
479479
Output = outputDirectory,
480480
GenerationMode = GenerationMode.Transform,
481-
Transform = "https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/mm/xslt/transforms/csdl/preprocess_csdl.xsl"
481+
Transform = "https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/transforms/csdl/preprocess_csdl.xsl"
482482

483483
};
484484

0 commit comments

Comments
 (0)