public virtual ApiSalesPersonQuotaHistoryResponseModel MapBOToModel(
            BOSalesPersonQuotaHistory boSalesPersonQuotaHistory)
        {
            var model = new ApiSalesPersonQuotaHistoryResponseModel();

            model.SetProperties(boSalesPersonQuotaHistory.BusinessEntityID, boSalesPersonQuotaHistory.ModifiedDate, boSalesPersonQuotaHistory.QuotaDate, boSalesPersonQuotaHistory.Rowguid, boSalesPersonQuotaHistory.SalesQuota);

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

            var client = new ApiClient(testServer.CreateClient());
            ApiSalesPersonQuotaHistoryResponseModel response = await client.SalesPersonQuotaHistoryGetAsync(1);

            response.Should().NotBeNull();
        }
Esempio n. 3
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiSalesPersonQuotaHistoryResponseModel response = await this.SalesPersonQuotaHistoryService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
Esempio n. 4
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiSalesPersonQuotaHistoryModelMapper();
            var model  = new ApiSalesPersonQuotaHistoryResponseModel();

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

            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.QuotaDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.SalesQuota.Should().Be(1m);
        }
        public void MapBOToModel()
        {
            var mapper = new BOLSalesPersonQuotaHistoryMapper();
            BOSalesPersonQuotaHistory bo = new BOSalesPersonQuotaHistory();

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

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

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <SalesPersonQuotaHistory>(null));
            var service = new SalesPersonQuotaHistoryService(mock.LoggerMock.Object,
                                                             mock.RepositoryMock.Object,
                                                             mock.ModelValidatorMockFactory.SalesPersonQuotaHistoryModelValidatorMock.Object,
                                                             mock.BOLMapperMockFactory.BOLSalesPersonQuotaHistoryMapperMock,
                                                             mock.DALMapperMockFactory.DALSalesPersonQuotaHistoryMapperMock);

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

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

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

            ApiSalesPersonQuotaHistoryResponseModel model = await client.SalesPersonQuotaHistoryGetAsync(1);

            ApiSalesPersonQuotaHistoryModelMapper mapper = new ApiSalesPersonQuotaHistoryModelMapper();

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

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

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

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

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

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

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

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

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

                UpdateResponse <ApiSalesPersonQuotaHistoryResponseModel> result = await this.SalesPersonQuotaHistoryService.Update(id, model);

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

            response.Should().NotBeNull();
        }