public void ShouldHaveNotPassWhenAddAsyncNullItemReturnThrowException()
        {
            //arrange
            var thirdItem = new ItemTodo();

            //actual

            //assert
            Assert.ThrowsAsync <DbUpdateException>(async() => await _itemToDoService.AddAsync(thirdItem));
        }
        public async Task ShouldHavePassWhenAddAsyncItem()
        {
            //arrange
            var thirdItem = new ItemTodo()
            {
                Id = Guid.Parse("74a1eedc-0719-408c-8c07-1bee8c2dd0b1"), Name = "Third Item"
            };
            await _itemToDoService.AddAsync(thirdItem);

            //actual
            var actualItems = await _itemToDoService.BrowsAsync();

            //assert
            Assert.That(actualItems.Any(x => x.Id == thirdItem.Id));
            Assert.AreEqual(3, actualItems.Count());
        }
        public void Init()
        {
            //arrange
            _dbContext = new AppDbContext(InMemoryWithEfDatabase());
            _dbContext.Database.EnsureCreated();

            var repository = new Mock <ItemToDoRepository>(_dbContext);

            _itemToDoService = new ItemToDoInMemoryService(repository.Object);

            _items = new[] { _firstItem, _secondItem };

            foreach (var item in _items)
            {
                _itemToDoService.AddAsync(item);
            }
        }
        public async Task <IActionResult> OnPostAddAsync()
        {
            if (!ModelState.IsValid)
            {
                var items = await _itemToDoInMemoryService.BrowsAsync();

                ItemToDos = items.Select(x => new ItemToDoViewModel
                {
                    Id   = x.Id,
                    Name = x.Name
                }).ToList();

                return(Page());
            }

            await _itemToDoInMemoryService.AddAsync(new ItemTodo
            {
                Id   = Guid.NewGuid(),
                Name = ItemToDo.Name
            });

            return(RedirectToPage());
        }