Пример #1
0
        public async Task GetAsync_FindAllNotes_AllPersistedNotesReturned()
        {
            MockedNoteRepository
            .GetAllAsync()
            .Returns(AllNotes);

            var expectedNotes = AllNotes;

            var(actualNotes, responseMessage) = await GetExecutedResponse <IEnumerable <Note> >(Controller.GetAsync);

            Assert.Multiple(() =>
            {
                Assert.That(responseMessage.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.That(actualNotes, Is.EqualTo(expectedNotes).UsingNoteComparer());
            });
        }
Пример #2
0
        public async Task DeleteAsync_DeleteNoteById_DeletedNoteReturned()
        {
            MockedNoteRepository
            .DeleteByIdAsync(Note4.Id)
            .Returns(Note4);

            MockedRetrievalService
            .Exists(Note4.Id)
            .Returns(returnThis: true);


            var(actualNote, responseMessage) =
                await GetExecutedResponse <Note>(() => Controller.DeleteAsync(Note4.Id));

            Assert.Multiple(() =>
            {
                Assert.That(responseMessage.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                Assert.That(Controller.ModelState.Count, Is.EqualTo(expected: 0));
                Assert.That(actualNote, Is.EqualTo(Note4).UsingNoteComparer());
            });
        }