public virtual ApiPersonPhoneResponseModel MapBOToModel(
            BOPersonPhone boPersonPhone)
        {
            var model = new ApiPersonPhoneResponseModel();

            model.SetProperties(boPersonPhone.BusinessEntityID, boPersonPhone.ModifiedDate, boPersonPhone.PhoneNumber, boPersonPhone.PhoneNumberTypeID);

            return(model);
        }
        public async void TestGet()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());
            ApiPersonPhoneResponseModel response = await client.PersonPhoneGetAsync(1);

            response.Should().NotBeNull();
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiPersonPhoneModelMapper();
            var model  = new ApiPersonPhoneResponseModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1);
            ApiPersonPhoneRequestModel response = mapper.MapResponseToRequest(model);

            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PhoneNumber.Should().Be("A");
            response.PhoneNumberTypeID.Should().Be(1);
        }
Exemple #4
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiPersonPhoneResponseModel response = await this.PersonPhoneService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
        public void MapBOToModel()
        {
            var           mapper = new BOLPersonPhoneMapper();
            BOPersonPhone bo     = new BOPersonPhone();

            bo.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1);
            ApiPersonPhoneResponseModel response = mapper.MapBOToModel(bo);

            response.BusinessEntityID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PhoneNumber.Should().Be("A");
            response.PhoneNumberTypeID.Should().Be(1);
        }
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IPersonPhoneRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <PersonPhone>(null));
            var service = new PersonPhoneService(mock.LoggerMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.PersonPhoneModelValidatorMock.Object,
                                                 mock.BOLMapperMockFactory.BOLPersonPhoneMapperMock,
                                                 mock.DALMapperMockFactory.DALPersonPhoneMapperMock);

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

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
        public async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            ApiPersonPhoneResponseModel model = await client.PersonPhoneGetAsync(1);

            ApiPersonPhoneModelMapper mapper = new ApiPersonPhoneModelMapper();

            UpdateResponse <ApiPersonPhoneResponseModel> updateResponse = await client.PersonPhoneUpdateAsync(model.BusinessEntityID, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }
Exemple #8
0
        public async void Create_Errors()
        {
            PersonPhoneControllerMockFacade mock = new PersonPhoneControllerMockFacade();

            var mockResponse = new Mock <CreateResponse <ApiPersonPhoneResponseModel> >(new FluentValidation.Results.ValidationResult());
            var mockRecord   = new ApiPersonPhoneResponseModel();

            mockResponse.SetupGet(x => x.Success).Returns(false);

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiPersonPhoneRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiPersonPhoneResponseModel> >(mockResponse.Object));
            PersonPhoneController controller = new PersonPhoneController(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.Create(new ApiPersonPhoneRequestModel());

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiPersonPhoneRequestModel>()));
        }
Exemple #9
0
        public async void All_Exists()
        {
            PersonPhoneControllerMockFacade mock = new PersonPhoneControllerMockFacade();
            var record  = new ApiPersonPhoneResponseModel();
            var records = new List <ApiPersonPhoneResponseModel>();

            records.Add(record);
            mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            PersonPhoneController controller = new PersonPhoneController(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);

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

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Exemple #10
0
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiPersonPhoneRequestModel> patch)
        {
            ApiPersonPhoneResponseModel record = await this.PersonPhoneService.Get(id);

            if (record == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                ApiPersonPhoneRequestModel model = await this.PatchModel(id, patch);

                UpdateResponse <ApiPersonPhoneResponseModel> result = await this.PersonPhoneService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
Exemple #11
0
        public async void TestGet()
        {
            ApiPersonPhoneResponseModel response = await this.Client.PersonPhoneGetAsync(1);

            response.Should().NotBeNull();
        }