static void VerifyLinkValid( RandomCustomerFromListFixture item, Func<SpCustomerApi.CustomerSummary.Links, SpCustomerApi.Link> linkSelector ) { var linksSet = item.Selected._links; Assert.NotNull( linksSet ); var linkToVerify = linkSelector( linksSet ); VerifyLink.LinkWellFormed( linkToVerify ); }
public GetRandomCustomerFixture( SpCustomerApi api, RandomCustomerFromListFixture list ) { //Now query the API for that specific customer by following the self link from the item in the Index obtained in the previous step var linkedAddress = list.Selected._links.self; var apiResult = api.GetCustomer( linkedAddress.href ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); DataFromGet = apiResult.Data; }
public static void ShouldHaveAnOrganizationLink( [Frozen] SpCustomerApi api, RandomCustomerFromListFixture preSelectedCustomer ) { var linkedAddress = preSelectedCustomer.Selected._links.self; //Now query the API for that specific customer by following the link obtained in the previous step var apiResult = api.GetCustomer( linkedAddress.href ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); var customer = apiResult.Data; VerifyLink.LinkWellFormed( customer._links.organizationAdd ); }
public static void GetNonExistingCustomerShould404( [Frozen] SpCustomerApi api, RandomCustomerFromListFixture customer, Guid anonymousId ) { string validHref = customer.Selected._links.self.href; var invalidHref = UriHelper.HackLinkReplacingGuidWithAlternateValue( anonymousId, validHref ); var apiResult = api.GetCustomer( invalidHref ); // We don't want to have landed on an error page that has a StatusCode of 200 Assert.Equal( HttpStatusCode.NotFound, apiResult.StatusCode ); // Our final Location should match what we asked for Assert.Contains( invalidHref.ToString(), apiResult.ResponseUri.ToString() ); }
public static void GetCustomerShouldContainData( [Frozen] SpCustomerApi api, RandomCustomerFromListFixture preSelectedCustomer ) { var linkedAddress = preSelectedCustomer.Selected._links.self; //Now query the API for that specific customer by following the link obtained in the previous step var apiResult = api.GetCustomer( linkedAddress.href ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); //The customer obtained as a separate resource should be identical to the customer previously selected from the list apiResult.Data.AsSource().OfLikeness<SpCustomerApi.CustomerSummary>() .Without( p => p._links ) .Without( p => p._signature ) .With( x => x._embedded ) .EqualsWhen( ( x, y ) => x._embedded.Invitation == null ) .ShouldEqual( preSelectedCustomer.Selected ); }
public static void ShouldAppearInUnassignedLicensesListing( [Frozen] SpIssueApi api, RandomLicenseFromListFixture license, RandomCustomerFromListFixture customer ) { var licenseCustomerAssignmentHref = license.Selected._links.customerAssignment.href; var apiResult = api.DeleteLicenseCustomerAssignment( licenseCustomerAssignmentHref ); Assert.Contains( apiResult.StatusCode, new[] { HttpStatusCode.NoContent, HttpStatusCode.NotFound } ); // TODO assert order in xUnit.net should be reversed Verify.EventuallyWithBackOff( () => { var updated = api.GetLicenseList( "$filter=Customer eq null&$expand=Customer" ); var licenseData = VerifyResponse( updated ); // No licenses within this filtered set should show a customer link Assert.True( licenseData.All( x => x._links.customer == null ) ); // Despite asking for Customer data to be expanded, no licenses within this filtered set should have a customer property included Assert.True( licenseData.All( x => x._embedded.Customer == null ) ); } ); }
public static void ShouldHaveAValidSelfLink( RandomCustomerFromListFixture item ) { VerifyLinkValid( item, links => links.self ); }
public static void ShouldHaveANonNullDescription( RandomCustomerFromListFixture item ) { Assert.NotNull( item.Selected.ExternalId ); }
public static void ShouldHaveAName( RandomCustomerFromListFixture item ) { Assert.NotEmpty( item.Selected.Name ); }
static void FilterByKnownExternalIdShouldReturnOneOrMoreCustomersWithThatExternalId( SpCustomerApi api, RandomCustomerFromListFixture preSelectedCustomer ) { var id = preSelectedCustomer.Selected.ExternalId; var response = api.GetCustomerList( "$filter=ExternalId eq '" + id + '"' ); Assert.True( response.Data.results.All( x => id == x.ExternalId ), "Did not find '" + id + "' in: " + string.Join( ", ", from r in response.Data.results select r.ExternalId ) ); }