public async Task Should_Throw_When_Add_Duplicate_TaskList()
        {
            ITaskListRepository taskListRepo = new TaskListRepository(
                _fxt.Database.GetCollection <TaskList>("task-lists")
                );

            await Assert.ThrowsAsync <DuplicateKeyException>(() =>
                                                             taskListRepo.AddAsync(new TaskList {
                DisplayId = "groceries", OwnerId = "bobby"
            })
                                                             );
        }
        public async Task Should_Add_New_TaskList()
        {
            // insert a new task list into the collection
            TaskList taskList;
            {
                ITaskListRepository taskListRepo = new TaskListRepository(
                    _fxt.Database.GetCollection <TaskList>("task-lists")
                    );
                taskList = new TaskList
                {
                    DisplayId = "GROCERIes",
                    Title     = "My Groceries List",
                    OwnerId   = "bobby",
                };
                await taskListRepo.AddAsync(taskList);
            }

            // ensure task list object is updated
            {
                Assert.Equal("My Groceries List", taskList.Title);
                Assert.Equal("groceries", taskList.DisplayId);
                Assert.Equal("bobby", taskList.OwnerId);
                Assert.NotNull(taskList.Id);
                Assert.True(ObjectId.TryParse(taskList.Id, out _), "Entity's ID should be a Mongo ObjectID.");
                Assert.InRange(taskList.CreatedAt, DateTime.UtcNow.AddSeconds(-5), DateTime.UtcNow);

                Assert.Null(taskList.Description);
                Assert.Null(taskList.Tags);
                Assert.Null(taskList.Collaborators);
                Assert.Null(taskList.ModifiedAt);
            }

            // ensure task list document is created in the collection
            {
                BsonDocument taskListDocument = _fxt.Database
                                                .GetCollection <BsonDocument>("task-lists")
                                                .FindSync(FilterDefinition <BsonDocument> .Empty)
                                                .Single();

                Assert.Equal(
                    BsonDocument.Parse($@"{{
                        _id: ObjectId(""{taskList.Id}""),
                        name: ""groceries"",
                        owner: ""bobby"",
                        title: ""My Groceries List"",
                        created: ISODate(""{taskList.CreatedAt:O}"")
                    }}"),
                    taskListDocument
                    );
            }
        }