Пример #1
0
        public async void FindPersonRoute_Test()
        {
            // Arrange
            var newPerson = CreatePerson();

            _personRepository
            .Setup(x => x.Single(It.IsAny <Expression <Func <Person, bool> > >()))
            .ReturnsAsync(newPerson);

            var personController = new PersonController(_personRepository.Object, _mapper, _emailHelper.Object, _tokenClass.Object);

            // Act
            var result = await personController.FindPersonAsync(newPerson.Name);

            var okResult           = result as OkObjectResult;
            var returnedPersonjson = okResult.Value as string;
            var returnedPerson     = JsonSerializer.Deserialize <PersonDto>(returnedPersonjson);

            // Assert
            Assert.True(okResult != null);
            Assert.True(returnedPerson != null);
            Assert.Equal(200, okResult.StatusCode);
        }