Beispiel #1
0
        public virtual ApiVStateProvinceCountryRegionResponseModel MapBOToModel(
            BOVStateProvinceCountryRegion boVStateProvinceCountryRegion)
        {
            var model = new ApiVStateProvinceCountryRegionResponseModel();

            model.SetProperties(boVStateProvinceCountryRegion.StateProvinceID, boVStateProvinceCountryRegion.CountryRegionCode, boVStateProvinceCountryRegion.CountryRegionName, boVStateProvinceCountryRegion.IsOnlyStateProvinceFlag, boVStateProvinceCountryRegion.StateProvinceCode, boVStateProvinceCountryRegion.StateProvinceName, boVStateProvinceCountryRegion.TerritoryID);

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

            response.Should().NotBeNull();
        }
Beispiel #3
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiVStateProvinceCountryRegionResponseModel response = await this.VStateProvinceCountryRegionService.Get(id);

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

            model.SetProperties(1, "A", "A", true, "A", "A", 1);
            ApiVStateProvinceCountryRegionRequestModel response = mapper.MapResponseToRequest(model);

            response.CountryRegionCode.Should().Be("A");
            response.CountryRegionName.Should().Be("A");
            response.IsOnlyStateProvinceFlag.Should().Be(true);
            response.StateProvinceCode.Should().Be("A");
            response.StateProvinceName.Should().Be("A");
            response.TerritoryID.Should().Be(1);
        }
        public void MapBOToModel()
        {
            var mapper = new BOLVStateProvinceCountryRegionMapper();
            BOVStateProvinceCountryRegion bo = new BOVStateProvinceCountryRegion();

            bo.SetProperties(1, "A", "A", true, "A", "A", 1);
            ApiVStateProvinceCountryRegionResponseModel response = mapper.MapBOToModel(bo);

            response.CountryRegionCode.Should().Be("A");
            response.CountryRegionName.Should().Be("A");
            response.IsOnlyStateProvinceFlag.Should().Be(true);
            response.StateProvinceCode.Should().Be("A");
            response.StateProvinceID.Should().Be(1);
            response.StateProvinceName.Should().Be("A");
            response.TerritoryID.Should().Be(1);
        }
Beispiel #6
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IVStateProvinceCountryRegionRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <VStateProvinceCountryRegion>(null));
            var service = new VStateProvinceCountryRegionService(mock.LoggerMock.Object,
                                                                 mock.RepositoryMock.Object,
                                                                 mock.ModelValidatorMockFactory.VStateProvinceCountryRegionModelValidatorMock.Object,
                                                                 mock.BOLMapperMockFactory.BOLVStateProvinceCountryRegionMapperMock,
                                                                 mock.DALMapperMockFactory.DALVStateProvinceCountryRegionMapperMock);

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

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

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

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