public void NotesRepositoryDeleteCallsDeletesFromTheUnitOfWork() { // Arrange var user = new User { PartitionKey = User1PartitionKey, RowKey = User1RowKey }; var taskList = new TaskList("Test title", user) { PartitionKey = TaskList1PartitionKey, RowKey = _taskList1RowKey }; var note = new Note("Test title", "Test content", user, taskList) { PartitionKey = Note1PartitionKey, RowKey = _note1RowKey }; var taskListNote = new TaskListEntity(string.Format("{0}+{1}", TaskList1PartitionKey, _taskList1RowKey), string.Format("{0}+{1}", Note1PartitionKey, _note1RowKey)); var unitOfWorkMock = new Mock<IUnitOfWork>(); unitOfWorkMock.Setup(uow => uow.Get("TaskListNotes", It.IsAny<Expression<Func<TaskListEntity, bool>>>())).Returns(taskListNote); unitOfWorkMock.Setup(uow => uow.Load<NoteShareEntity>(It.Is<string>(s => s == "NoteShares"))).Returns(BuildNoteSharesTable()); var repository = new NotesRepository(unitOfWorkMock.Object); // Act repository.Delete(note); // Assert unitOfWorkMock.Verify(uow => uow.Delete<NoteEntity>("Notes", Note1PartitionKey, _note1RowKey), Times.Once()); unitOfWorkMock.Verify(uow => uow.Delete<TaskListEntity>("TaskListNotes", taskListNote.PartitionKey, taskListNote.RowKey), Times.Once()); unitOfWorkMock.Verify(uow => uow.Delete<NoteShareEntity>("NoteShares", string.Format("{0}+{1}", Note1PartitionKey, _note1RowKey), User1RowKey), Times.Once()); unitOfWorkMock.Verify(uow => uow.Delete<NoteShareEntity>("NoteShares", string.Format("{0}+{1}", Note1PartitionKey, _note1RowKey), User3RowKey), Times.Once()); }