public void GetLoyaltyEventNamesTestCaseTest(int errorCode, string errorMessage) { LWController lwController = new LWController(Database, TestStep); try { TestStep.Start("Make GetLoyaltyEventNames Call", $"GetLoyaltyEventNames call should throw exception with error code = {errorCode}"); LWServiceException exception = Assert.Throws <LWServiceException>(() => lwController.GetLoyaltyEventNames(string.Empty), "Expected LWServiceException, exception was not thrown."); Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}"); Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}"); TestStep.Pass("GetLoyaltyEventNames call threw expected exception", exception.ReportDetail()); } catch (AssertionException ex) { TestStep.Fail(ex.Message); Assert.Fail(); } catch (AssertModelEqualityException ex) { TestStep.Fail(ex.Message, ex.ComparisonFailures); Assert.Fail(); } catch (Exception ex) { TestStep.Abort(ex.Message, ex.StackTrace); Assert.Fail(); } }
public void HTZUpdateTier_Negative(string csAgent, int errorCode, string errorMessage) { LWController lwController = new LWController(Database, TestStep); try { TestStep.Start($"Make HertzGetCSAgent Call", $"HertzGetCSAgent call should throw exception with error code = {errorCode}"); LWServiceException exception = Assert.Throws <LWServiceException>(() => lwController.HertzGetCSAgent(csAgent), "Expected LWServiceException, exception was not thrown."); Assert.AreEqual(errorCode, exception.ErrorCode); Assert.IsTrue(exception.Message.Contains(errorMessage)); TestStep.Pass("HertzGetCSAgent call threw expected exception", exception.ReportDetail()); } catch (AssertModelEqualityException ex) { TestStep.Fail(ex.Message, ex.ComparisonFailures); Assert.Fail(); } catch (Exception ex) { TestStep.Abort(ex.Message); Assert.Fail(); } }
public string Get(string plate) { var datalist = _context.vehiculos.Where(p => p.Placa == plate); var count = datalist.Count <Vehiculo>(); if (count == 1) { var plateData = datalist.First <Vehiculo>(); var provider = plateData.gps_provider; var deviceId = plateData.gps_id; var vehicle = new VehiculoGps(); if (provider.Equals("CGB")) { CGBController cgb = new CGBController(); vehicle = cgb.getPlate(plate); _context.vehiculosGps.Add(vehicle); _context.SaveChanges(); } else if (provider.Equals("LOCATION-WORLD")) { LWController lw = new LWController(); var token = lw.getToken(); var clientId = lw.getClientId(token); lw.getDataDevices(token); var obj = lw.getVehicleData(deviceId, token, clientId); } else if (provider.Contains("CHEVISTAR")) { } } //foreach (var elem in datalist) //{ // Console.WriteLine(elem); //} return(""); }
public void HertzGetCSAgent_Positive(string csAgent) { LWController lwController = new LWController(Database, TestStep); try { TestStep.Start($"Make HertzGetCSAgent Call", "HertzGetCSAgent call should return HertzGetCSAgentResponseModel object"); HertzGetCSAgentResponseModel hertzGetCSAgentResponse = lwController.HertzGetCSAgent(csAgent); Assert.IsNotNull(hertzGetCSAgentResponse, "Expected populated HertzGetCSAgentResponseModel object, but HertzUpdateTierResponseModel object returned was null"); TestStep.Pass("HertzGetCSAgentResponseModel object was returned", hertzGetCSAgentResponse.AgentUserName); TestStep.Start($"Verify CSAgent values", "CSAgent values returned should be correct"); Assert.AreEqual(csAgent.ToUpper(), hertzGetCSAgentResponse.AgentUserName.ToUpper()); TestStep.Pass("New Tier values response is as expcted", hertzGetCSAgentResponse.AgentUserName); } catch (AssertionException ex) { TestStep.Fail(ex.Message); Assert.Fail(); } catch (LWServiceException ex) { TestStep.Fail(ex.Message, new[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {ex.ErrorMessage}" }); Assert.Fail(); } catch (AssertModelEqualityException ex) { TestStep.Fail(ex.Message, ex.ComparisonFailures); Assert.Fail(); } catch (Exception ex) { TestStep.Abort(ex.Message); Assert.Fail(); } }
public void GetRewardCatalog_Positive(bool?activeOnly, int?batchSize, long?currencyToEarnLow, long?currencyToEarnHigh) { LWController lwController = new LWController(Database, TestStep); try { TestStep.Start($"Make GetRewardCatalog Call", "GetRewardCatalog call should return RewardCatalogSummaryResponseModel object"); List <RewardCatalogSummaryResponseModel> rewardCatalogSummaryResponse = lwController.GetRewardCatalog(activeOnly, "", "", null, null, null, 1, batchSize, currencyToEarnLow, currencyToEarnHigh); Assert.IsNotNull(rewardCatalogSummaryResponse, "Expected populated RewardCatalogSummaryResponseModel object, but RewardCatalogSummaryResponseModel object returned was null"); Assert.AreNotEqual(0, rewardCatalogSummaryResponse.Count); TestStep.Pass("RewardCatalogSummaryResponseModel object was returned", rewardCatalogSummaryResponse.Count.ToString()); TestStep.Start($"Verify Reward Catalog values", "Reward Catalog values returned should be correct"); if (batchSize != null) { Assert.IsTrue(rewardCatalogSummaryResponse.Count <= batchSize); } if (activeOnly != null && activeOnly == true) { int inactiveRewards = rewardCatalogSummaryResponse .Where(x => x.CatalogEndDate.Date < DateTime.Now.Date) .Count(); Assert.AreEqual(0, inactiveRewards); } if (currencyToEarnLow != null && currencyToEarnLow > 0) { int rewardsWithLowerValue = rewardCatalogSummaryResponse .Where(x => x.CurrencyToEarn < currencyToEarnLow) .Count(); Assert.AreEqual(0, rewardsWithLowerValue); } if (currencyToEarnHigh != null && currencyToEarnHigh > 0) { int rewardsWithHigherValue = rewardCatalogSummaryResponse .Where(x => x.CurrencyToEarn > currencyToEarnHigh) .Count(); Assert.AreEqual(0, rewardsWithHigherValue); } TestStep.Pass("RewardCatalog response is as expcted", rewardCatalogSummaryResponse.Count.ToString()); } catch (AssertionException ex) { TestStep.Fail(ex.Message); Assert.Fail(); } catch (LWServiceException ex) { TestStep.Fail(ex.Message, new[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {ex.ErrorMessage}" }); Assert.Fail(); } catch (AssertModelEqualityException ex) { TestStep.Fail(ex.Message, ex.ComparisonFailures); Assert.Fail(); } catch (Exception ex) { TestStep.Abort(ex.Message); Assert.Fail(); } }