public virtual ApiBusinessEntityContactResponseModel MapBOToModel(
            BOBusinessEntityContact boBusinessEntityContact)
        {
            var model = new ApiBusinessEntityContactResponseModel();

            model.SetProperties(boBusinessEntityContact.BusinessEntityID, boBusinessEntityContact.ContactTypeID, boBusinessEntityContact.ModifiedDate, boBusinessEntityContact.PersonID, boBusinessEntityContact.Rowguid);

            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());
            ApiBusinessEntityContactResponseModel response = await client.BusinessEntityContactGetAsync(1);

            response.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiBusinessEntityContactResponseModel response = await this.BusinessEntityContactService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiBusinessEntityContactModelMapper();
            var model  = new ApiBusinessEntityContactResponseModel();

            model.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            ApiBusinessEntityContactRequestModel response = mapper.MapResponseToRequest(model);

            response.ContactTypeID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PersonID.Should().Be(1);
            response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Exemplo n.º 5
0
        public void MapBOToModel()
        {
            var mapper = new BOLBusinessEntityContactMapper();
            BOBusinessEntityContact bo = new BOBusinessEntityContact();

            bo.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            ApiBusinessEntityContactResponseModel response = mapper.MapBOToModel(bo);

            response.BusinessEntityID.Should().Be(1);
            response.ContactTypeID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PersonID.Should().Be(1);
            response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Exemplo n.º 6
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IBusinessEntityContactRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <BusinessEntityContact>(null));
            var service = new BusinessEntityContactService(mock.LoggerMock.Object,
                                                           mock.RepositoryMock.Object,
                                                           mock.ModelValidatorMockFactory.BusinessEntityContactModelValidatorMock.Object,
                                                           mock.BOLMapperMockFactory.BOLBusinessEntityContactMapperMock,
                                                           mock.DALMapperMockFactory.DALBusinessEntityContactMapperMock);

            ApiBusinessEntityContactResponseModel 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());

            ApiBusinessEntityContactResponseModel model = await client.BusinessEntityContactGetAsync(1);

            ApiBusinessEntityContactModelMapper mapper = new ApiBusinessEntityContactModelMapper();

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

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }
Exemplo n.º 8
0
        public async void Create_Errors()
        {
            BusinessEntityContactControllerMockFacade mock = new BusinessEntityContactControllerMockFacade();

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

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

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

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiBusinessEntityContactRequestModel>()));
        }
Exemplo n.º 9
0
        public async void All_Exists()
        {
            BusinessEntityContactControllerMockFacade mock = new BusinessEntityContactControllerMockFacade();
            var record  = new ApiBusinessEntityContactResponseModel();
            var records = new List <ApiBusinessEntityContactResponseModel>();

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

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
Exemplo n.º 10
0
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiBusinessEntityContactRequestModel> patch)
        {
            ApiBusinessEntityContactResponseModel record = await this.BusinessEntityContactService.Get(id);

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

                UpdateResponse <ApiBusinessEntityContactResponseModel> result = await this.BusinessEntityContactService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
        public async void TestGet()
        {
            ApiBusinessEntityContactResponseModel response = await this.Client.BusinessEntityContactGetAsync(1);

            response.Should().NotBeNull();
        }