public async Task RepositoryWithoutTaskDefinitionsReturnsEmptyList() { var builder = TestsHelper.SetupInMemoryDatabase(Guid.NewGuid().ToString()); using (var context = new TimedTodoContext(builder.Options)) { var repository = new TimedTodoRepository(context); var taskDefinitions = await repository.GetTaskDefinitionsAsync(); Assert.IsTrue(taskDefinitions.ToList().Count == 0); } }
public async Task RepositoryWithoutTaskDefinitionReturnsNull() { var builder = TestsHelper.SetupInMemoryDatabase(Guid.NewGuid().ToString()); using (var context = new TimedTodoContext(builder.Options)) { var repository = new TimedTodoRepository(context); var taskDefinition = await repository.GetTaskDefinitionAsync(Guid.NewGuid()); Assert.IsNull(taskDefinition); } }
public async Task RepositoryCanGetTaskDefinitions() { var builder = TestsHelper.SetupInMemoryDatabase(Guid.NewGuid().ToString()); var seededTaskDefininitions = TestsHelper.SeedMultipleTaskDefinitions(builder.Options, 3) .OrderBy(t => t.Id).ToList(); using (var context = new TimedTodoContext(builder.Options)) { var repository = new TimedTodoRepository(context); var taskDefinitions = (await repository.GetTaskDefinitionsAsync()).OrderBy(t => t.Id).ToList(); CollectionAssert.AreEqual(seededTaskDefininitions, taskDefinitions, taskDefinitionComparer); } }
public async Task RepositoryCanGetTaskDefinition() { var builder = TestsHelper.SetupInMemoryDatabase(Guid.NewGuid().ToString()); Guid taskDefinitionId = TestsHelper.SeedTaskDefinition(builder.Options); using (var context = new TimedTodoContext(builder.Options)) { var repository = new TimedTodoRepository(context); var retrievedTaskDefinition = await repository.GetTaskDefinitionAsync(taskDefinitionId); Assert.AreEqual(taskDefinitionId, retrievedTaskDefinition.Id); } }
public async Task RepositoryCanAddTaskDefinition() { var taskDefinition = new TaskDefinition { Title = "Task Definition", DefaultTimeSpan = new TimeSpan(), }; var builder = TestsHelper.SetupInMemoryDatabase(Guid.NewGuid().ToString()); using (var context = new TimedTodoContext(builder.Options)) { var repo = new TimedTodoRepository(context); repo.AddTaskDefinition(taskDefinition); await repo.SaveChangesAsync(); var savedTaskDefinition = (await repo.GetTaskDefinitionsAsync()).First(); Assert.AreEqual(0, (new TaskDefinitionComparer().Compare(taskDefinition, savedTaskDefinition))); } }