Пример #1
0
        public async Task Create_CreateResidentWithIncompleteData_ReturnsBadRquest()
        {
            // Arrange
            // _mockResidentRepository.Setup(repo => repo.Add(It.IsAny<Resident>()));

            var controller = new ResidentsController(_mockResidentRepository.Object,
                                                     _mockUoW.Object, _mapper);

            controller.ModelState.AddModelError("Email", "Required");

            // Act
            var residentViewModel = new ResidentViewModel {
                Name = "John Cena"
            };
            var addResidentResult = await controller.Create(residentViewModel);

            // assert
            Assert.IsInstanceOf <BadRequestObjectResult>(addResidentResult);
        }
Пример #2
0
        public async Task Create_CreateResidentWithCompleteData_ReturnsOKResult()
        {
            // Arrange
            var controller = new ResidentsController(_mockResidentRepository.Object,
                                                     _mockUoW.Object, _mapper);

            // Act
            var residentViewModel = new ResidentViewModel
            {
                Name      = "John Cena",
                Email     = "*****@*****.**",
                Block     = "B",
                Apartment = "301",
                Cpf       = "3243141431"
            };

            var addResidentResult = await controller.Create(residentViewModel);

            // assert
            Assert.IsInstanceOf <OkObjectResult>(addResidentResult);
            var okResult = addResidentResult as OkObjectResult;

            Assert.IsInstanceOf <ResidentViewModel>(okResult.Value);
        }