public void MapServerResponseToRequest()
        {
            var mapper = new ApiVPersonServerModelMapper();
            var model  = new ApiVPersonServerResponseModel();

            model.SetProperties(1, "A");
            ApiVPersonServerRequestModel response = mapper.MapServerResponseToRequest(model);

            response.Should().NotBeNull();
            response.PersonName.Should().Be("A");
        }
Exemple #2
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiVPersonServerResponseModel response = await this.VPersonService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <IVPersonService, IVPersonRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <VPerson>(null));
            var service = new VPersonService(mock.LoggerMock.Object,
                                             mock.MediatorMock.Object,
                                             mock.RepositoryMock.Object,
                                             mock.ModelValidatorMockFactory.VPersonModelValidatorMock.Object,
                                             mock.DALMapperMockFactory.DALVPersonMapperMock);

            ApiVPersonServerResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
        public async void All_Exists()
        {
            VPersonControllerMockFacade mock = new VPersonControllerMockFacade();
            var record  = new ApiVPersonServerResponseModel();
            var records = new List <ApiVPersonServerResponseModel>();

            records.Add(record);
            mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(Task.FromResult(records));
            VPersonController controller = new VPersonController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.All(1000, 0, string.Empty);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var items = (response as OkObjectResult).Value as List <ApiVPersonServerResponseModel>;

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()));
        }