Skip to content

Commit 0ae176b

Browse files
committed
Test - Add CamelCaseNaming Converter unit test
Resolves #2
1 parent 426b4c5 commit 0ae176b

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright © 2020 The CefSharp Authors. All rights reserved.
2+
//
3+
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4+
5+
using Xunit;
6+
using CefSharp.Extensions.ModelBinding;
7+
8+
namespace CefSharp.Extensions.Test.ModelBinding
9+
{
10+
public class ModelBindingExtensionsFacts
11+
{
12+
[Theory]
13+
[InlineData("A", "A")]
14+
[InlineData("AB", "AB")]
15+
[InlineData("AString", "aString")]
16+
[InlineData("aString", "aString")]
17+
public void ConvertStringToCamelCaseTheory(string input, string expected)
18+
{
19+
var actual = input.ConvertNameToCamelCase();
20+
21+
Assert.Equal(expected, actual);
22+
}
23+
}
24+
}

CefSharp.Extensions/CefSharp.Extensions.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,11 @@
3030
</None>
3131
</ItemGroup>
3232

33+
<ItemGroup>
34+
<!-- As per https://www.meziantou.net/declaring-internalsvisibleto-in-the-csproj.htm -->
35+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
36+
<_Parameter1>CefSharp.Extensions.Test</_Parameter1>
37+
</AssemblyAttribute>
38+
</ItemGroup>
39+
3340
</Project>

CefSharp.Extensions/ModelBinding/ModelBindingExtensions.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -421,31 +421,21 @@ public static bool IsCustomStruct(this Type source)
421421
}
422422

423423
/// <summary>
424-
/// Converts the name of a method into camelCase
424+
/// Converts the name of a property/method into camelCase
425425
/// </summary>
426-
/// <param name="method">the method which will have it's name converted</param>
427-
/// <returns>the camel case version of the method name.</returns>
428-
public static string ConvertNameToCamelCase(this MethodInfo method)
429-
{
430-
return ConvertNameToCamelCase(method.Name);
431-
}
432-
433-
/// <summary>
434-
/// Converts the name of a property into camelCase
435-
/// </summary>
436-
/// <param name="property">the property which will have it's name converted</param>
426+
/// <param name="memberInfo">the property/method which will have it's name converted</param>
437427
/// <returns>the camel case version of the property name.</returns>
438-
public static string ConvertNameToCamelCase(this PropertyInfo property)
428+
public static string ConvertNameToCamelCase(this MemberInfo memberInfo)
439429
{
440-
return ConvertNameToCamelCase(property.Name);
430+
return ConvertNameToCamelCase(memberInfo.Name);
441431
}
442432

443433
/// <summary>
444434
/// Converts a string (usually .NET value of some sort) to a camelCase representation.
445435
/// </summary>
446436
/// <param name="sourceString"></param>
447437
/// <returns>the string converted to camelCase or preserved based on it's original structure.</returns>
448-
private static string ConvertNameToCamelCase(this string sourceString)
438+
internal static string ConvertNameToCamelCase(this string sourceString)
449439
{
450440
// don't allow whitespace in property names.
451441
// because we use this in the actual binding process, we should be throwing and not allowing invalid entries.

0 commit comments

Comments
 (0)