|
2 | 2 | using System.Linq;
|
3 | 3 | using Xunit;
|
4 | 4 |
|
5 |
| -namespace Tests |
| 5 | +using static System.ReadLine; |
| 6 | + |
| 7 | +namespace ReadLine.Tests |
6 | 8 | {
|
7 |
| - public class Tests : IDisposable |
| 9 | + public class ReadLineTests : IDisposable |
8 | 10 | {
|
9 |
| - public Tests() |
| 11 | + public ReadLineTests() |
10 | 12 | {
|
11 | 13 | string[] history = new string[] { "ls -a", "dotnet run", "git init" };
|
12 |
| - ReadLine.AddHistory(history); |
| 14 | + AddHistory(history); |
13 | 15 | }
|
14 | 16 |
|
15 | 17 | [Fact]
|
16 | 18 | public void TestNoInitialHistory()
|
17 | 19 | {
|
18 |
| - Assert.Equal(3, ReadLine.GetHistory().Count); |
| 20 | + Assert.Equal(3, GetHistory().Count); |
19 | 21 | }
|
20 | 22 |
|
21 | 23 | [Fact]
|
22 | 24 | public void TestUpdatesHistory()
|
23 | 25 | {
|
24 |
| - ReadLine.AddHistory("mkdir"); |
25 |
| - Assert.Equal(4, ReadLine.GetHistory().Count); |
| 26 | + AddHistory("mkdir"); |
| 27 | + Assert.Equal(4, GetHistory().Count); |
| 28 | + Assert.Equal("mkdir", GetHistory().Last()); |
26 | 29 | }
|
27 | 30 |
|
28 | 31 | [Fact]
|
29 | 32 | public void TestGetCorrectHistory()
|
30 | 33 | {
|
31 |
| - var history = ReadLine.GetHistory(); |
32 |
| - |
33 |
| - Assert.Equal(3, history.Count); |
34 |
| - Assert.Equal("git init", history.Last()); |
| 34 | + Assert.Equal("ls -a", GetHistory()[0]); |
| 35 | + Assert.Equal("dotnet run", GetHistory()[1]); |
| 36 | + Assert.Equal("git init", GetHistory()[2]); |
35 | 37 | }
|
36 | 38 |
|
37 | 39 | public void Dispose()
|
38 | 40 | {
|
39 | 41 | // If all above tests pass
|
40 | 42 | // clear history works
|
41 |
| - ReadLine.ClearHistory(); |
| 43 | + ClearHistory(); |
42 | 44 | }
|
43 | 45 | }
|
44 | 46 | }
|
0 commit comments