public void WhenResponseIsNull_ReturnsNull() { var vendor3Service = new Vendor3ServiceWrapper(null, null, null); var response = $"<quote />"; Assert.Null(vendor3Service.ParseResponse(response)); }
public void WhenResponseContainsQuote_ReturnsValue(decimal val) { var vendor3Service = new Vendor3ServiceWrapper(null, null, null); var response = $"<quote>{val}</quote>"; Assert.Equal(val, vendor3Service.ParseResponse(response)); }
public void WhenCredentialsAreNotFound_ReturnsNullAuthHeader(string username, string password) { var vendorService = new Vendor3ServiceWrapper(null, null, new Mocks.CredentialsProviderMock(username, password)); var header = vendorService.GetAuthorizationHeaderValue(); Assert.Null(header.Parameter); }
public void WhenResponseContainsOtherProperties_ReturnsTotal() { var vendor3Service = new Vendor3ServiceWrapper(null, null, null); var response = "<xml><quote>4.45</quote><desc>Description</desc></xml>"; Assert.Equal(4.45m, vendor3Service.ParseResponse(response)); }
public void WhenCredentialsAreValid_CreatesAuthheader(string username, string password) { var vendorService = new Vendor3ServiceWrapper(null, null, new Mocks.CredentialsProviderMock(username, password)); var header = vendorService.GetAuthorizationHeaderValue(); var bytes = Encoding.ASCII.GetBytes(string.Format("{0}:{1}", username, password)); var base64AuthString = Convert.ToBase64String(bytes); var testHeader = new AuthenticationHeaderValue("Basic", base64AuthString); Assert.Equal(testHeader.Parameter, header.Parameter); }
public void WhenResponseIsInvalid_ReturnsNull() { var vendor3Service = new Vendor3ServiceWrapper(null, null, null); var response = "<amount />"; // don't want the app to crash if the vendor changes the api contract Assert.Null(vendor3Service.ParseResponse(response)); // handle unexpected response Assert.Null(vendor3Service.ParseResponse("error")); }