Esempio n. 1
0
        public async Task Should_ReturnUnprocessableEntity_IfModelIsNotValid()
        {
            ControllerMock.ModelState.AddModelError("test", "error");

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

            Assert.IsType <UnprocessableEntityResult>(response);
        }
Esempio n. 2
0
        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);
        }