Beispiel #1
0
        public async Task CreateAsync_Should_Create_Item()
        {
            using (var context = await InMemoryDbContext.GetContext().SeedDabase(TestSeed.GetItemsForTesting()))
            {
                //arrange
                var repository = new ToDoItemRepository(context);

                //act
                var itemToAdd = new Item
                {
                    Name = "Find Princess Leia",
                    AdditionalInformation = "Princess has been abducted, we have to find her!",
                    Completed             = false,
                    Deadline    = DateTime.Today.AddDays(1),
                    LastUpdated = DateTime.Today,
                    UserId      = Guid.NewGuid()
                };

                var totalCount = await context.ToDoItems.CountAsync();

                var result = await repository.CreateAsync(itemToAdd);

                //assert
                result.Should().NotBeNull();
                result.Id.Should().NotBe(Guid.Empty);
                context.ToDoItems.Count().Should().Be(totalCount + 1);
            }
        }