Created
July 15, 2022 15:14
-
-
Save jkeam/7c8621ba3dffdc980682c080011bce10 to your computer and use it in GitHub Desktop.
Validation tests to add for todo application, found here: https://github.com/jkeam/TodoList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Snippet to add to TodoListTest/Tests.cs | |
[Test] | |
public void NotAllowCreateShortTodo() | |
{ | |
using (var scope = testContext.Services.CreateScope()) | |
{ | |
var service = scope.ServiceProvider.GetRequiredService<IDbContextFactory<DatabaseContext>>(); | |
using (var context = service.CreateDbContext()) | |
{ | |
Assert.AreEqual(1, context.Todos.ToList().Count); | |
var component = testContext.RenderComponent<TodoList.Pages.Todos>(); | |
var inputField = component.Find("input"); | |
inputField.Change("1"); | |
component.Find("button[type=submit].new-todo").Click(); | |
var todos = context.Todos.ToList(); | |
Assert.AreEqual(1, todos.Count); | |
} | |
} | |
} | |
[Test] | |
public void NotAllowCreateLongTodo() | |
{ | |
using (var scope = testContext.Services.CreateScope()) | |
{ | |
var service = scope.ServiceProvider.GetRequiredService<IDbContextFactory<DatabaseContext>>(); | |
using (var context = service.CreateDbContext()) | |
{ | |
Assert.AreEqual(1, context.Todos.ToList().Count); | |
var component = testContext.RenderComponent<TodoList.Pages.Todos>(); | |
var inputField = component.Find("input"); | |
inputField.Change("012345678901234567890123456789012345678901234567890123456789"); | |
component.Find("button[type=submit].new-todo").Click(); | |
var todos = context.Todos.ToList(); | |
Assert.AreEqual(1, todos.Count); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment