public async Task Test_List() { var console = new Mock <IMyConsole>(MockBehavior.Loose); var ctx = new MyDbContext(InMemoryDbCreator.CreateInMemoryOptions <MyDbContext>("Test_List")); await ctx.ToDos.AddRangeAsync(new ToDo() { Id = Guid.NewGuid(), Text = "Existing1", Written = DateTime.UtcNow }, new ToDo() { Id = Guid.NewGuid(), Text = "Existing2", Written = DateTime.UtcNow }); await ctx.SaveChangesAsync(); var list = new ListTodos(NullLoggerFactory.Instance, ctx, console.Object); console.Setup(p => p.WriteLine(It.IsAny <string>())); await list.ListAsync(); console.Verify(p => p.WriteLine("Existing1"), Times.Once); console.Verify(p => p.WriteLine("Existing2"), Times.Once); }
public async Task Test_EmptyList() { var console = new Mock <IMyConsole>(MockBehavior.Loose); var ctx = new MyDbContext(InMemoryDbCreator.CreateInMemoryOptions <MyDbContext>("Test_EmptyList")); var list = new ListTodos(NullLoggerFactory.Instance, ctx, console.Object); console.Setup(p => p.WriteLine(It.IsAny <string>())); await list.ListAsync(); console.Verify(p => p.WriteLine("No TODOs in database. Add one and try again."), Times.Once); }
public static void Main(string[] args) { string?gitRoot = FindGitInfo(); if (gitRoot == null) { Console.Error.WriteLine("Couldn't find root of git repository."); Environment.Exit(1); } Console.WriteLine($"Found git repository: {gitRoot}"); Repository repository = new Repository(gitRoot); if (args.Length < 1) { PrintUsage(); Environment.Exit(0); } Command?command = default; switch (args[0]) { case "list": command = new ListTodos(repository); break; case "create": command = new CreateTodos(repository); break; case "clean": command = new CleanTodos(repository); break; } if (command == null) { PrintUsage(); Environment.Exit(0); } command.Execute(); }