-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitTests.cs
72 lines (67 loc) · 1.93 KB
/
UnitTests.cs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using FluentAssertions;
using System.Collections.Generic;
using Xunit;
namespace DeveloperTests
{
public class ProgramTests
{
[Fact]
public void Main_should_not_throw()
{
Program.Main(null);
}
}
public class WordCounterTests
{
[Fact]
public void ByWord_should_count_words()
{
var (byWord, _) = WordCounter.Do("I have a transportation device which is a red bike which I love to ride.");
byWord.Should().BeEquivalentTo(new Dictionary<string, int>
{
{"I", 2},
{"have", 1},
{"a", 2},
{"transportation", 1},
{"device", 1},
{"which", 2},
{"is", 1},
{"red", 1},
{"bike", 1},
{"love", 1},
{"to", 1},
{"ride", 1},
});
}
[Fact]
public void ByLenght_should_count_word_by_length()
{
var (_, byLenght) = WordCounter.Do("I have a transportation device which is a red bike which I love to ride.");
byLenght.Should().BeEquivalentTo(new Dictionary<int, int>
{
{1, 4},
{2, 2},
{3, 1},
{4, 4},
{5, 2},
{6, 1},
{14, 1},
});
}
}
public class StringReverserTests
{
[Fact]
public void Should_reverse_string()
{
var actual = StringReverser.Do("I have a transportation device which is a red bike which I love to ride.");
actual.Should().Be(".edir ot evol I hcihw ekib der a si hcihw ecived noitatropsnart a evah I");
}
[Fact]
public void Should_handle_empty_string()
{
var actual = StringReverser.Do("");
actual.Should().Be("");
}
}
}