public void GetNotes_IfGetNotes_GetsNotesSuccess() { // arrange const int accountId = 1; var note = new NoteDTO { Id = 1, Account = new AccountDTO(), Image = new byte[] { }, ModifyTime = DateTime.Now, PublishTime = DateTime.Now, Title = Guid.NewGuid().ToString(), Text = Guid.NewGuid().ToString() }; var notes = new[] { note }; _loggerMock.Setup(_ => _.Info(It.IsAny <string>())); _noteServiceMock.Setup(_ => _.GetNotes(accountId)).Returns(notes); // act var statusInfo = _sut.GetNotes(accountId); // assert _loggerMock.Verify(_ => _.Info(It.IsAny <string>()), Times.Exactly(2)); _noteServiceMock.Verify(_ => _.GetNotes(accountId), Times.Once); Assert.True(statusInfo.OperationStatus == OperationStatus.Success); Assert.True(notes.SequenceEqual(statusInfo.AttachedObject)); Assert.Equal(note.Id, statusInfo.AttachedObject[0].Id); Assert.Equal(note.Account, statusInfo.AttachedObject[0].Account); Assert.Equal(note.Image, statusInfo.AttachedObject[0].Image); Assert.Equal(note.ModifyTime, statusInfo.AttachedObject[0].ModifyTime); Assert.Equal(note.PublishTime, statusInfo.AttachedObject[0].PublishTime); Assert.Equal(note.Title, statusInfo.AttachedObject[0].Title); Assert.Equal(note.Text, statusInfo.AttachedObject[0].Text); }
public List <NoteDTO> GetNotes(int accountId) { var operationStatusInfo = _remoteNotesClient.GetNotes(accountId); return(GetAttachedObject(operationStatusInfo)); }