コード例 #1
0
ファイル: GetAllTests.cs プロジェクト: DmitriyS1/Contacts
        public async Task Should_ReturnOk_IfContactsListIsEmpty()
        {
            ContactsRepositoryMock
            .Setup(r => r.GetAllAsync())
            .ReturnsAsync(new List <Contact>());

            var response = await ControllerMock.GetAll();

            Assert.IsType <OkObjectResult>(response);
        }
コード例 #2
0
        public async Task Should_ReturnOk()
        {
            ContactsRepositoryMock
            .Setup(cr => cr.GetAsync(It.IsAny <ObjectId>()))
            .ReturnsAsync(new Contact());

            var response = await ControllerMock.Get("5d2b5b105c20853204e52c8a");

            Assert.IsType <OkObjectResult>(response);
        }
コード例 #3
0
        public async Task Should_ReturnNotFound_IfContactNotExists()
        {
            ContactsRepositoryMock
            .Setup(cr => cr.GetAsync(It.IsAny <ObjectId>()))
            .ReturnsAsync(() => null);

            var response = await ControllerMock.Get("5d2b5b105c20853204e52c8a");

            Assert.IsType <NotFoundResult>(response);
        }
コード例 #4
0
ファイル: PostTests.cs プロジェクト: DmitriyS1/Contacts
        public async Task Should_ReturnOk()
        {
            MapperMock
            .Setup(m => m.Map <Contact>(It.IsAny <CreateContactModel>()))
            .Returns(new Contact());
            ContactsRepositoryMock
            .Setup(r => r.CreateAsync(It.IsAny <Contact>()))
            .Returns(Task.CompletedTask);

            var response = await ControllerMock.Post(It.IsAny <CreateContactModel>());

            Assert.IsType <OkResult>(response);
        }