public void CreateWorkItem_OnValidRequest_CreatesWorkItem() { // ARRANGE DbContextOptions <TestDatabaseContext> options = new DbContextOptionsBuilder <TestDatabaseContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; IDatabaseContext dbContext = new TestDatabaseContext(options); WorkItemRepository repository = new WorkItemRepository(dbContext); WorkItemPublic workItem = new WorkItemPublic() { Color = Guid.NewGuid().ToString(), WorkItemCollectionID = 1, Description = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString(), WorkItemEnd = DateTime.Now, WorkItemStart = DateTime.Now }; dbContext.WorkItemCollections.Add(new WorkItemCollection() { ID = 1, TaskBoardId = 1 }); dbContext.TaskBoards.Add(new TaskBoard() { ID = 1, UserID = 1 }); dbContext.Users.Add(new User() { ID = 1 }); dbContext.SaveChanges(); // ACT WorkItemPublic result = repository.CreateWorkItem(workItem); workItem.ID = result.ID; // ASSERT result.Should().BeEquivalentTo <WorkItemPublic>(workItem); }