public void WhenCredentialsAreNotFound_ReturnsNullAuthHeader(string username, string password) { var vendorService = new Vendor1ServiceWrapper(null, null, new Mocks.CredentialsProviderMock(username, password)); var header = vendorService.GetAuthorizationHeaderValue(); Assert.Null(header.Parameter); }
public void WhenResponseIsNull_ReturnsNull() { var vendorService = new Vendor1ServiceWrapper(null, null, null); var response = JsonConvert.SerializeObject(new{ total = (decimal?)null }); Assert.Null(vendorService.ParseResponse(response)); }
public void WhenResponseContainsTotal_ReturnsValue(decimal val) { var vendorService = new Vendor1ServiceWrapper(null, null, null); var response = JsonConvert.SerializeObject(new{ total = val }); Assert.Equal(val, vendorService.ParseResponse(response)); }
public void WhenCredentialsAreValid_CreatesAuthheader(string username, string password) { var vendorService = new Vendor1ServiceWrapper(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 vendorService = new Vendor1ServiceWrapper(null, null, null); var response = JsonConvert.SerializeObject(new { charge = 4.45m }); // don't want the app to crash if the vendor changes the api contract Assert.Null(vendorService.ParseResponse(response)); // handle unexpected response Assert.Null(vendorService.ParseResponse("error")); }
public void WhenResponseContainsOtherProperties_ReturnsTotal() { var vendorService = new Vendor1ServiceWrapper(null, null, null); var response = JsonConvert.SerializeObject( new { total = 4.45m, description = "new property" } ); Assert.Equal(4.45m, vendorService.ParseResponse(response)); }