Skip to content

Commit

Permalink
Refactored Markdown unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
cuhsat committed Jun 10, 2022
1 parent af555f5 commit b3cb193
Showing 1 changed file with 13 additions and 34 deletions.
47 changes: 13 additions & 34 deletions tests/Caliban.Todo.Tests/Data/TodoModelTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO;
using System.Threading.Tasks;
using System;
using Caliban.Todo.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand All @@ -8,49 +7,29 @@ namespace Caliban.Todo.Tests.Data
[TestClass]
public sealed class TodoModelTests
{
private const string Testfile = @".\Test.md";
private readonly string[] Testdata = new[] {
private readonly string[] Markdown = new[] {
"# TODO",
"* Test 1",
"* Test 2",
"* Test 3"
"* Test 3",
""
};

[TestMethod]
public async Task RequestTest()
public void MarkdownTest()
{
var model = new TodoModel();

await model.Request(Testfile);

Assert.AreEqual(model.Items.Count, 3);

for (var i = 0; i < model.Items.Count; i++)
var model = new TodoModel
{
Assert.AreEqual(model.Items[i], $"Test {i + 1}");
}
}
Header = "TODO"
};

[TestMethod]
public async Task PersistTest()
{
var model = new TodoModel();
model.Items.Add("Test 1");
model.Items.Add("Test 2");
model.Items.Add("Test 3");

for (var i = 1; i < 4; i++)
{
model.Items.Add($"Test {i}");
}

await model.Persist(Testfile);

var lines = await File.ReadAllLinesAsync(Testfile);
var markdown = string.Join(Environment.NewLine, Markdown);

Assert.AreEqual(lines.Length, Testdata.Length);

for (var i = 0; i < lines.Length; i++)
{
Assert.AreEqual(lines[i], Testdata[i]);
}
Assert.AreEqual(markdown, model.ToString());
}
}
}

0 comments on commit b3cb193

Please sign in to comment.