public void NotesRepositoryGetWihtFilterCallsGetFromTheUnitOfWorkAndReturnsAnExistingNote() { // 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); var unitOfWorkMock = new Mock<IUnitOfWork>(); unitOfWorkMock.Setup(u => u.Get("Notes", It.IsAny<Expression<Func<Note, bool>>>())).Returns(note); var repository = new NotesRepository(unitOfWorkMock.Object); // Act var result = repository.Get(n => n.PartitionKey == Note1PartitionKey && n.RowKey == _note1RowKey); // Assert Assert.IsNotNull(result); unitOfWorkMock.Verify(uow => uow.Get("Notes", It.IsAny<Expression<Func<Note, bool>>>()), Times.Once()); }
public void NotesRepositoryGetCallsGetFromTheUnitOfWorkAndReturnsNullForANonExistingNote() { // Arrange var unitOfWorkMock = new Mock<IUnitOfWork>(); var repository = new NotesRepository(unitOfWorkMock.Object); // Act var result = repository.Get(Note3PartitionKey, _note3RowKey); // Assert Assert.IsNull(result); unitOfWorkMock.Verify(uow => uow.Get("Notes", It.IsAny<Expression<Func<NoteEntity, bool>>>()), Times.Once()); }