Exemple #1
0
        public void Should_Success_Get_GarmentPreSalesContract()
        {
            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();

            Mock <IHttpClientService> httpClientService = new Mock <IHttpClientService>();

            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("merchandiser/garment-pre-sales-contracts"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(new GarmentPreSalesContractDataUtil().GetResultFormatterOkString())
            });

            serviceProvider
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var garmentPreSalesContract         = facade.GetGarmentPreSalesContract(It.IsAny <long>());

            Assert.NotNull(garmentPreSalesContract);
        }
Exemple #2
0
        public void Should_Error_Get_GarmentPreSalesContract()
        {
            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();

            Mock <IHttpClientService> httpClientService = new Mock <IHttpClientService>();

            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("merchandiser/garment-pre-sales-contracts"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.InternalServerError)
            {
                Content = new StringContent(string.Empty)
            });

            serviceProvider
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(serviceProvider.Object, _dbContext(GetCurrentMethod()));

            Exception exception = Assert.Throws <Exception>(() => facade.GetGarmentPreSalesContract(It.IsAny <long>()));

            Assert.NotNull(exception.Message);
        }