private static async Task <TodoListViewModel> CreateAndInitAsync() { _items = new[] { new TodoItem { Id = Guid.NewGuid(), Description = "Test" }, new TodoItem { Id = Guid.NewGuid(), Description = "Test 2" } }; _serviceMock = new TodoServiceMock(); _serviceMock.Items.AddRange(_items); var vm = new TodoListViewModel(_serviceMock); await vm.Init(); return(vm); }
private static async Task <TodoListViewModel> CreateAndInitAsync() { _items = new[] { new TodoItem { Id = Guid.NewGuid(), Description = "Test" }, new TodoItem { Id = Guid.NewGuid(), Description = "Test 2" } }; _serviceMock = new Mock <ITodoService>(); _serviceMock.Setup(m => m.LoadItemsAsync()).ReturnsAsync(_items); _serviceMock.Setup(m => m.InsertItemAsync(It.IsAny <string>())) .ReturnsAsync((string d) => new TodoItem { Id = Guid.NewGuid(), Description = d }); var vm = new TodoListViewModel(_serviceMock.Object); await vm.Init(); return(vm); }