|
@@ -0,0 +1,65 @@
|
|
1
|
+using System;
|
|
2
|
+using Luticate2.Utils.Utils;
|
|
3
|
+using Xunit;
|
|
4
|
+
|
|
5
|
+namespace TestUtils.Utils
|
|
6
|
+{
|
|
7
|
+ public class LuCoreUtilsExtensionsTest
|
|
8
|
+ {
|
|
9
|
+ [Fact]
|
|
10
|
+ public void TestStringToGuidNull()
|
|
11
|
+ {
|
|
12
|
+ string str = null;
|
|
13
|
+ Assert.Null(str.ToGuid());
|
|
14
|
+ }
|
|
15
|
+
|
|
16
|
+ [Fact]
|
|
17
|
+ public void TestStringToGuidValid()
|
|
18
|
+ {
|
|
19
|
+ var str = "365989fc-cbd6-11e6-99ca-3085a902d67c";
|
|
20
|
+ Assert.Equal(str, str.ToGuid().ToString());
|
|
21
|
+ }
|
|
22
|
+
|
|
23
|
+ [Fact]
|
|
24
|
+ public void TestStringToGuidInvalid()
|
|
25
|
+ {
|
|
26
|
+ var str = "42";
|
|
27
|
+ Assert.Throws<FormatException>(() => str.ToGuid());
|
|
28
|
+ }
|
|
29
|
+
|
|
30
|
+ [Fact]
|
|
31
|
+ public void TestStringToSnakeCaseNull()
|
|
32
|
+ {
|
|
33
|
+ string str = null;
|
|
34
|
+ Assert.Throws<ArgumentNullException>(() => str.ToSnakeCase());
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ [Fact]
|
|
38
|
+ public void TestStringToSnakeCaseEmpty()
|
|
39
|
+ {
|
|
40
|
+ var str = "";
|
|
41
|
+ Assert.Equal("", str.ToSnakeCase());
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ [Fact]
|
|
45
|
+ public void TestStringToSnakeCase1()
|
|
46
|
+ {
|
|
47
|
+ var str = "TestNotEmpty";
|
|
48
|
+ Assert.Equal("test_not_empty", str.ToSnakeCase());
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ [Fact]
|
|
52
|
+ public void TestStringToSnakeCase2()
|
|
53
|
+ {
|
|
54
|
+ var str = "testNotEmpty";
|
|
55
|
+ Assert.Equal("test_not_empty", str.ToSnakeCase());
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ [Fact]
|
|
59
|
+ public void TestStringToSnakeCase3()
|
|
60
|
+ {
|
|
61
|
+ var str = "DBContext";
|
|
62
|
+ Assert.Equal("d_b_context", str.ToSnakeCase());
|
|
63
|
+ }
|
|
64
|
+ }
|
|
65
|
+}
|