1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using Luticate2.Utils.Utils;
- using Xunit;
-
- namespace TestUtils.Utils
- {
- public class LuCoreUtilsExtensionsTest
- {
- [Fact]
- public void TestStringToOptGuidNull()
- {
- string str = null;
- Assert.Null(str.ToOptGuid());
- }
-
- [Fact]
- public void TestStringToGuidValid()
- {
- var str = "365989fc-cbd6-11e6-99ca-3085a902d67c";
- Assert.Equal(str, str.ToGuid().ToString());
- }
-
- [Fact]
- public void TestStringToGuidInvalid()
- {
- var str = "42";
- Assert.Throws<FormatException>(() => str.ToGuid());
- }
-
- [Fact]
- public void TestStringToSnakeCaseNull()
- {
- string str = null;
- Assert.Throws<ArgumentNullException>(() => str.ToSnakeCase());
- }
-
- [Fact]
- public void TestStringToSnakeCaseEmpty()
- {
- var str = "";
- Assert.Equal("", str.ToSnakeCase());
- }
-
- [Fact]
- public void TestStringToSnakeCase1()
- {
- var str = "TestNotEmpty";
- Assert.Equal("test_not_empty", str.ToSnakeCase());
- }
-
- [Fact]
- public void TestStringToSnakeCase2()
- {
- var str = "testNotEmpty";
- Assert.Equal("test_not_empty", str.ToSnakeCase());
- }
-
- [Fact]
- public void TestStringToSnakeCase3()
- {
- var str = "DBContext";
- Assert.Equal("d_b_context", str.ToSnakeCase());
- }
- }
- }
|