public async Task WhenICallTheApiWithAValidDateWithCallBackUri_ThenACorrectResponseIsReturned() { var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(SinceDateTime, "https://fss.ukho.gov.uk/batch/7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272", accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Exchange Set for datetime is returned {apiResponse.StatusCode}, instead of the expected 200."); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheApiWithACurrentOrFutureRFC1123DateTime_ThenABadRequestStatusIsReturned(int days) { string sinceDatetime = DateTime.Now.AddDays(days).AddHours(1).ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", CultureInfo.InvariantCulture); var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(sinceDatetime, accessToken : EssJwtToken); Assert.AreEqual(400, (int)apiResponse.StatusCode, $"Exchange Set for datetime is returned {apiResponse.StatusCode}, instead of the expected 400. For given date {sinceDatetime}"); var errorMessage = await apiResponse.ReadAsTypeAsync <ErrorDescriptionResponseModel>(); Assert.IsTrue(errorMessage.Errors.Any(e => e.Source == "sinceDateTime")); Assert.IsTrue(errorMessage.Errors.Any(e => e.Description == "Provided sinceDateTime cannot be a future date.")); }
public async Task WhenICallTheProductVersionApiWithInvalidB2cToken_ThenAnUnauthorisedResponseIsReturned() { string invalidB2cToken = EssB2CToken.Remove(EssB2CToken.Length - 2).Insert(EssB2CToken.Length - 2, "AA"); List <ProductVersionModel> ProductVersionData = new List <ProductVersionModel>(); ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 6)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, accessToken : invalidB2cToken); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); }
public async Task WhenICallExchangeSetProductIdentifierApiWithACancelledProduct_ThenCatalogueFileUpdatedWithEditionNumberZero() { ProductIdentifierModel.ProductIdentifier = new List <string>() { "DE516510" }; var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(ProductIdentifierModel.ProductIdentifier, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected status 200."); var apiResponseData = await apiResponse.ReadAsTypeAsync <ExchangeSetResponseModel>(); var batchStatusUrl = apiResponseData.Links.ExchangeSetBatchStatusUri.Href; var batchId = batchStatusUrl.Split('/')[5]; CleanUpBatchIdList.Add(batchId); var finalBatchStatusUrl = $"{Config.FssConfig.BaseUrl}/batch/{batchId}/status"; var batchStatus = await FssBatchHelper.CheckBatchIsCommitted(finalBatchStatusUrl.ToString(), FssJwtToken); Assert.AreEqual("Committed", batchStatus, $"Incorrect batch status is returned {batchStatus} for url {batchStatusUrl}, instead of the expected status Committed."); var downloadFileUrl = $"{Config.FssConfig.BaseUrl}/batch/{batchId}/files/{Config.ExchangeSetFileName}"; var extractDownloadedFolder = await FssBatchHelper.ExtractDownloadedFolder(downloadFileUrl.ToString(), FssJwtToken); var downloadFolder = FssBatchHelper.RenameFolder(extractDownloadedFolder); var downloadFolderPath = Path.Combine(Path.GetTempPath(), downloadFolder); //Verify Cancellation details var apiScsResponse = await ScsApiClient.GetProductIdentifiersAsync(Config.ExchangeSetProductType, ProductIdentifierModel.ProductIdentifier, ScsJwtToken); Assert.AreEqual(200, (int)apiScsResponse.StatusCode, $"Incorrect status code is returned {apiScsResponse.StatusCode}, instead of the expected status 200."); var apiScsResponseData = await apiScsResponse.ReadAsTypeAsync <CancellationResponseModel>(); foreach (var product in apiScsResponseData.Products) { var productName = product.ProductName; var editionNumber = product.Cancellation.EditionNumber; Assert.AreEqual(0, editionNumber, $"Incorrect edition number is returned {editionNumber}, instead of 0."); var updateNumber = product.UpdateNumbers[product.UpdateNumbers.Count - 1]; CancellationFileHelper.CheckCatalogueFileContent(Path.Combine(downloadFolderPath, Config.ExchangeSetEncRootFolder, Config.ExchangeSetCatalogueFile), editionNumber, updateNumber, batchId); CancellationFileHelper.CheckProductFileContent(Path.Combine(downloadFolderPath, Config.ExchangeSetProductFilePath, Config.ExchangeSetProductFile), productName, editionNumber); } }
public async Task WhenICallTheApiWithAnEmptyProductVersion_ThenABadRequestStatusIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, accessToken : EssJwtToken); Assert.AreEqual(400, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 400."); var errorMessage = await apiResponse.ReadAsTypeAsync <ErrorDescriptionResponseModel>(); Assert.IsTrue(errorMessage.Errors.Any(e => e.Source == "requestBody")); Assert.IsTrue(errorMessage.Errors.Any(e => e.Description == "Either body is null or malformed.")); }
public async Task WhenICallTheApiWithAnEmptyProductIdentifier_ThenABadRequestStatusIsReturned() { ProductIdentifierModel.ProductIdentifier = new List <string>(); var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(ProductIdentifierModel.ProductIdentifier, "https://fss.ukho.gov.uk/batch/7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272%22", accessToken : EssJwtToken); Assert.AreEqual(400, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected status 400."); var errorMessage = await apiResponse.ReadAsTypeAsync <ErrorDescriptionResponseModel>(); Assert.IsTrue(errorMessage.Errors.Any(e => e.Source == "requestBody")); Assert.IsTrue(errorMessage.Errors.Any(e => e.Description == "Either body is null or malformed.")); }
public async Task SetupAsync() { Config = new TestConfiguration(); ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress); FssApiClient = new FssApiClient(); ProductIdentifierModel = new ProductIdentifierModel(); DataHelper = new DataHelper(); AuthTokenProvider authTokenProvider = new AuthTokenProvider(); EssJwtToken = await authTokenProvider.GetEssToken(); FssJwtToken = await authTokenProvider.GetFssToken(); }
public async Task WhenICallTheDateTimeApiWithAValidB2cToken_ThenACorrectResponseIsReturned() { var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(SinceDateTime, accessToken : EssB2CToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 200."); //verify model structure await apiResponse.CheckModelStructureForSuccessResponse(); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheApiWithAValidProductIdentifiers_ThenACorrectResponseIsReturned() { var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(DataHelper.GetOnlyProductIdentifierData(), accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected status 200."); //verify FssBatchResponse await apiResponse.CheckFssBatchResponse(); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task SetupAsync() { Config = new TestConfiguration(); ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress); FssApiClient = new FssApiClient(); AuthTokenProvider authTokenProvider = new AuthTokenProvider(); EssJwtToken = await authTokenProvider.GetEssToken(); EssJwtTokenNoRole = await authTokenProvider.GetEssTokenNoAuth(); EssJwtCustomizedToken = authTokenProvider.GenerateCustomToken(); FssJwtToken = await authTokenProvider.GetFssToken(); }
public async Task WhenICallExchangeSetApiWithProductIdentifiers_AndCalledClearCache_ThenItsClearTheCache() { //Get the product details form sales catalogue service var apiScsResponse = await ScsApiClient.GetProductIdentifiersAsync(Config.ExchangeSetProductType, new List <string>() { "DE290001" }, ScsJwtToken); Assert.AreEqual(200, (int)apiScsResponse.StatusCode, $"Incorrect status code is returned {apiScsResponse.StatusCode}, instead of the expected status 200."); var apiScsResponseData = await apiScsResponse.ReadAsTypeAsync <ScsProductResponseModel>(); foreach (var product in apiScsResponseData.Products) { string productName = product.ProductName; int editionNumber = product.EditionNumber; //Enc file download verification foreach (var updateNumber in product.UpdateNumbers) { await FileContentHelper.GetDownloadedEncFilesAsync(Config.FssConfig.BaseUrl, Path.Combine(DownloadedFolderPath, Config.ExchangeSetEncRootFolder), productName, editionNumber, updateNumber, FssJwtToken); } } var partitionKey = apiScsResponseData.Products[0].ProductName; var rowKey = apiScsResponseData.Products[0].EditionNumber + "|" + apiScsResponseData.Products[0].UpdateNumbers[0]; Console.WriteLine("Storange conn " + Config.EssStorageAccountConnectionString); Console.WriteLine("table cache " + Config.ClearCacheConfig.FssSearchCacheTableName); Console.WriteLine("connection string " + Config.ClearCacheConfig.CacheStorageConnectionString); //Check caching info var tableCacheCheck = (FssSearchResponseCache)await ClearCacheHelper.RetrieveFromTableStorageAsync <FssSearchResponseCache>(partitionKey, rowKey, Config.ClearCacheConfig.FssSearchCacheTableName, Config.ClearCacheConfig.CacheStorageConnectionString); // Verify the Cache is generated Assert.IsNotNull(tableCacheCheck); Assert.IsNotEmpty(tableCacheCheck.Response); var essCacheJson = JObject.Parse(@"{""Type"":""uk.gov.UKHO.FileShareService.NewFilesPublished.v1""}"); essCacheJson["Source"] = "AcceptanceTest"; essCacheJson["Id"] = "25d6c6c1-418b-40f9-bb76-f6dfc0f133bc"; essCacheJson["Data"] = JObject.FromObject(GetCacheRequestData()); var apiClearCacheResponse = await ExchangeSetApiClient.PostNewFilesPublishedAsync(essCacheJson, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiClearCacheResponse.StatusCode, $"Incorrect status code is returned for clear cache endpoint {apiClearCacheResponse.StatusCode}, instead of the expected status 200."); //Check caching info tableCacheCheck = (FssSearchResponseCache)await ClearCacheHelper.RetrieveFromTableStorageAsync <FssSearchResponseCache>(partitionKey, rowKey, Config.ClearCacheConfig.FssSearchCacheTableName, Config.ClearCacheConfig.CacheStorageConnectionString); // Verify the No Cache available Assert.IsNull(tableCacheCheck); }
public async Task SetupAsync() { Config = new TestConfiguration(); ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress); FssApiClient = new FssApiClient(); AuthTokenProvider authTokenProvider = new AuthTokenProvider(); EssJwtToken = await authTokenProvider.GetEssToken(); FssJwtToken = await authTokenProvider.GetFssToken(); DataHelper = new DataHelper(); ScsApiClient = new SalesCatalogueApiClient(Config.ScsAuthConfig.BaseUrl); ScsJwtToken = await authTokenProvider.GetScsToken(); }
public async Task WhenICallTheApiWithAValidRFC1123DateTime_ThenACorrectResponseIsReturned() { string sinceDatetime = DateTime.Now.AddDays(-5).ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", CultureInfo.InvariantCulture); var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(sinceDatetime, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 200."); //verify FssBatchResponse await apiResponse.CheckFssBatchResponse(); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheApiWithNoRoleToken_ThenACorrectResponseIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 1)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, accessToken : EssJwtTokenNoRole); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheApiWithNullProductVersion_ThenABadRequestStatusIsReturned(string productName, int?editionNumber, int?updateNumber, string sourceMessage, string descriptionMessage) { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData(productName, editionNumber, updateNumber)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, "https://fss.ukho.gov.uk/batch/7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272", accessToken : EssJwtToken); Assert.AreEqual(400, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 400."); var errorMessage = await apiResponse.ReadAsTypeAsync <ErrorDescriptionResponseModel>(); Assert.IsTrue(errorMessage.Errors.Any(e => e.Source == sourceMessage)); Assert.IsTrue(errorMessage.Errors.Any(e => e.Description == descriptionMessage)); }
public async Task SetupAsync() { Config = new TestConfiguration(); ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress); FssApiClient = new FssApiClient(); AuthTokenProvider authTokenProvider = new AuthTokenProvider(); AzureB2CAuthTokenProvider b2cAuthTokenProvider = new AzureB2CAuthTokenProvider(); EssB2CToken = await b2cAuthTokenProvider.GetToken(); FssJwtToken = await authTokenProvider.GetFssToken(); EssB2CCustomizedToken = b2cAuthTokenProvider.GenerateCustomToken(); DataHelper = new DataHelper(); }
public async Task WhenICallTheApiWithAValidProductVersionWithCallbackURI_ThenASuccessStatusIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE4NO18Q", 2, 0)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, "https://fss.ukho.gov.uk/batch/7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272", accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task SetupAsync() { Config = new TestConfiguration(); ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress); FssApiClient = new FssApiClient(); AuthTokenProvider authTokenProvider = new AuthTokenProvider(); EssJwtToken = await authTokenProvider.GetEssToken(); FssJwtToken = await authTokenProvider.GetFssToken(); DataHelper = new DataHelper(); var ApiEssResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(new List <string>() { "DE260001" }, accessToken : EssJwtToken); Assert.AreEqual(200, (int)ApiEssResponse.StatusCode, $"Incorrect status code is returned {ApiEssResponse.StatusCode}, instead of the expected status 200."); }
public async Task WhenICallTheProductVersionApiWithAValidB2cToken_ThenTheCorrectResponseIsReturned() { List <ProductVersionModel> ProductVersionData = new List <ProductVersionModel>(); ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 1)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, accessToken : EssB2CToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); //verify model structure await apiResponse.CheckModelStructureForSuccessResponse(); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheApiWithDuplicateProductIdentifiers_ThenACorrectResponseIsReturned() { ProductIdentifierModel.ProductIdentifier = new List <string>() { "DE5NOBRK", "DE5NOBRK" }; var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(ProductIdentifierModel.ProductIdentifier, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected status 200."); //verify model structure await apiResponse.CheckModelStructureNotModifiedResponse(); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task SetupAsync() { Config = new TestConfiguration(); ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress); FssApiClient = new FssApiClient(); AuthTokenProvider authTokenProvider = new AuthTokenProvider(); EssJwtToken = await authTokenProvider.GetEssToken(); FssJwtToken = await authTokenProvider.GetFssToken(); DataHelper = new DataHelper(); ScsApiClient = new SalesCatalogueApiClient(Config.ScsAuthConfig.BaseUrl); ScsJwtToken = await authTokenProvider.GetScsToken(); ApiEssResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(DataHelper.GetProductIdentifiers(), accessToken : EssJwtToken); //Get the BatchId var batchId = await ApiEssResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); DownloadedFolderPath = await FileContentHelper.CreateExchangeSetFile(ApiEssResponse, FssJwtToken); }
public async Task WhenICallTheApiWithAProductVersionNotAvailable_ThenASuccessStatusIsReturned(string productname, int editionnumber, int updatenumber) { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData(productname, editionnumber, updatenumber)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, "https://fss.ukho.gov.uk/batch/7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272", accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); var apiResponseData = await apiResponse.ReadAsTypeAsync <ExchangeSetResponseModel>(); //Verify requested product count Assert.AreEqual(1, apiResponseData.RequestedProductCount, $"Response body returned RequestedProductCount {apiResponseData.RequestedProductCount}, Instead of expected count is 1."); Assert.AreEqual(0, apiResponseData.RequestedProductsAlreadyUpToDateCount, $"Response body returned RequestedProductsAlreadyUpToDateCount : {apiResponseData.RequestedProductsAlreadyUpToDateCount}, Instead of expected RequestedProductsAlreadyUpToDateCount is 0."); // Verify ExchangeSetCellCount Assert.AreEqual(0, apiResponseData.ExchangeSetCellCount, $"Response body returned ExchangeSetCellCount {apiResponseData.ExchangeSetCellCount}, instead of expected ExchangeSetCellCount is 0."); //Check RequestedProductsNotInExchangeSet is not empty Assert.IsNotEmpty(apiResponseData.RequestedProductsNotInExchangeSet, "Response body returns Empty for RequestedProductsNotInExchangeSet, instead of Not Empty"); Assert.AreEqual("invalidProduct", apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason, $"Exchange set returned Reason {apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason}, instead of expected Reason 'invalidProduct'"); }
public async Task WhenICallTheApiWithInvalidProductIdentifiers_ThenACorrectResponseIsReturned() { ProductIdentifierModel.ProductIdentifier = new List <string>() { "GB123789" }; var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(ProductIdentifierModel.ProductIdentifier, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected status 200."); var apiResponseData = await apiResponse.ReadAsTypeAsync <ExchangeSetResponseModel>(); //Verify requested product count Assert.AreEqual(1, apiResponseData.RequestedProductCount, $"Response body returned RequestedProductCount {apiResponseData.RequestedProductCount}, Instead of expected count is 1."); Assert.AreEqual(0, apiResponseData.RequestedProductsAlreadyUpToDateCount, $"Response body returned RequestedProductsAlreadyUpToDateCount : {apiResponseData.RequestedProductsAlreadyUpToDateCount}, Instead of expected RequestedProductsAlreadyUpToDateCount is 0."); // Verify ExchangeSetCellCount Assert.AreEqual(0, apiResponseData.ExchangeSetCellCount, $"Response body returned ExchangeSetCellCount {apiResponseData.ExchangeSetCellCount}, instead of expected ExchangeSetCellCount is 0."); //Check RequestedProductsNotInExchangeSet is not empty Assert.IsNotEmpty(apiResponseData.RequestedProductsNotInExchangeSet, "Response body returns Empty for RequestedProductsNotInExchangeSet, instead of Not Empty"); Assert.AreEqual("invalidProduct", apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason, $"Exchange set returned Reason {apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason}, instead of expected Reason 'invalidProduct'"); }
public async Task WhenICallTheApiWithValidAndInvalidProductVersion_ThenTheCorrectResponseIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 1)); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("GB123789", 1, 0)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); //verify model structure await apiResponse.CheckModelStructureForSuccessResponse(); var apiResponseData = await apiResponse.ReadAsTypeAsync <ExchangeSetResponseModel>(); Assert.AreEqual("GB123789", apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().ProductName, $"Exchange set returned Product Name {apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().ProductName}, instead of expected Product Name 'GB123789'"); Assert.AreEqual("invalidProduct", apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason, $"Exchange set returned Reason {apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason}, instead of expected Reason 'invalidProduct'"); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheApiWithValidAndInvalidProductIdentifiers_ThenACorrectResponseIsReturned() { ProductIdentifierModel.ProductIdentifier = new List <string>() { "DE4NO18Q", "GB123789" }; var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(ProductIdentifierModel.ProductIdentifier, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected status 200."); //verify model structure await apiResponse.CheckModelStructureForSuccessResponse(); var apiResponseData = await apiResponse.ReadAsTypeAsync <ExchangeSetResponseModel>(); Assert.AreEqual("GB123789", apiResponseData.RequestedProductsNotInExchangeSet.LastOrDefault().ProductName, $"Exchange set returned Product Name {apiResponseData.RequestedProductsNotInExchangeSet.LastOrDefault().ProductName}, instead of expected Product Name 'GB123789'"); Assert.AreEqual("invalidProduct", apiResponseData.RequestedProductsNotInExchangeSet.LastOrDefault().Reason, $"Exchange set returned Reason {apiResponseData.RequestedProductsNotInExchangeSet.LastOrDefault().Reason}, instead of expected Reason 'invalidProduct'"); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheDateTimeApiWithCustomB2cToken_ThenAnUnauthorisedResponseIsReturned() { var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(SinceDateTime, accessToken : EssB2CCustomizedToken); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); }
public async Task WhenICallTheProductIdentifierApiWithCustomB2cToken_ThenAnUnauthorisedResponseIsReturned() { var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(DataHelper.GetProductIdentifierData(), accessToken : EssB2CCustomizedToken); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); }