-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathStringExtensionsTests.cs
More file actions
40 lines (33 loc) · 901 Bytes
/
StringExtensionsTests.cs
File metadata and controls
40 lines (33 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using NUnit.Framework;
using Simplify.System.Extensions;
namespace Simplify.System.Tests.Extensions;
[TestFixture]
public class StringExtensionsTests
{
[Test]
public void String_ToBytesArray_ConvertedCorrectly()
{
Assert.That("test".ToBytesArray(), Is.EqualTo(new byte[] { 116, 0, 101, 0, 115, 0, 116, 0 }));
}
[Test]
public void TryToDateTimeExact_CorrectValue_ConvertedCorrectly()
{
// Assign
const string str = "12.03.13";
// Act
var time = str.TryToDateTimeExact("dd.MM.yy");
// Assert
Assert.That(time, Is.Not.Null);
Assert.That(time!.Value.Day, Is.EqualTo(12));
Assert.That(time.Value.Month, Is.EqualTo(3));
Assert.That(time.Value.Year, Is.EqualTo(2013));
}
[Test]
public void TryToDateTimeExact_WrongValue_ConvertedCorrectly()
{
// Assign
const string str = "test";
// Act & Assert
Assert.That(str.TryToDateTimeExact("dd.MM.yy"), Is.Null);
}
}