static string PutPendingCreate( SpCustomerApi api, string anonymousCustomerName, string anonymousCustomerExternalId, Guid anonymousRequestId ) { var response = api.CreateCustomer( new SpCustomerApi.CustomerSummary() { Name = anonymousCustomerName, ExternalId = anonymousCustomerExternalId, RequestId = anonymousRequestId } ); Assert.Equal( HttpStatusCode.Accepted, response.StatusCode ); var createdAtLocation = Assert.IsType<string>( response.Headers.Single( x => x.Name == "Location" ).Value ); return createdAtLocation; }
public IRestResponse PutLicenseCustomerAssignment( string licenseCustomerAssignmentHref, SpCustomerApi.CustomerSummary customer ) { var request = new RestRequest( licenseCustomerAssignmentHref, Method.PUT ); request.RequestFormat = DataFormat.Json; request.AddBody( customer ); return Execute( request ); }
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 ShouldYieldAcceptedWithALocationHref( SpCustomerApi api, string anonymousCustomerName, string anonymousCustomerExternalId, Guid anonymousRequestId ) { var response = api.CreateCustomer( new SpCustomerApi.CustomerSummary() { Name = anonymousCustomerName, ExternalId = anonymousCustomerExternalId, RequestId = anonymousRequestId } ); Assert.Equal( HttpStatusCode.Accepted, response.StatusCode ); string result = Assert.IsType<string>( response.Headers.Single( x => x.Name == "Location" ).Value ); Assert.NotEmpty( result ); }
public RandomCustomerFromListFixture( SpCustomerApi api ) { var apiResult = api.GetCustomerList(); Assert.Equal( ResponseStatus.Completed, apiResult.ResponseStatus ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); Assert.NotNull( apiResult.Data.results ); Assert.True( apiResult.Data.results.Any(), GetType().Name + " requires the target login to have at least one Customer" ); Selected = apiResult.Data.results.ElementAtRandom(); }
public FreshCustomerFixture( SpCustomerApi api, string customerName, string customerExternalId, Guid requestId ) { var response = api.CreateCustomer( new SpCustomerApi.CustomerSummary { Name = customerName, ExternalId = customerExternalId, RequestId = requestId } ); Assert.Equal( HttpStatusCode.Accepted, response.StatusCode ); string location = Assert.IsType<string>( response.Headers.Single( x => x.Name == "Location" ).Value ); var signedCustomer = GetCustomer( api, location ); SignedCustomer = signedCustomer.Data; }
static IRestResponse<SpCustomerApi.CustomerSummary> GetCustomer( SpCustomerApi api, string location ) { var apiResult = default(IRestResponse<SpCustomerApi.CustomerSummary>); Verify.EventuallyWithBackOff( () => { apiResult = api.GetCustomer( location ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); } ); return apiResult; }
public static void ShouldEventuallyBeGettable( SpCustomerApi api, string anonymousCustomerName, string anonymousCustomerExternalId, Guid anonymousRequestId ) { string createdAtLocation = PutPendingCreate( api, anonymousCustomerName, anonymousCustomerExternalId, anonymousRequestId ); Verify.EventuallyWithBackOff( () => { var apiResult = api.GetCustomer( createdAtLocation ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); var resultData = apiResult.Data; } ); }
public static void PutExcessivelyLongShouldReject( SpCustomerApi api, string anonymousName ) { var response = api.CreateCustomer( new SpCustomerApi.CustomerSummary() { Name = anonymousName, ExternalId = new String( 'a', 101 ) } ); Assert.Equal( HttpStatusCode.BadRequest, response.StatusCode ); }
public static void PutEmptyShouldReject( SpCustomerApi api, string anonymousExternalId ) { var response = api.CreateCustomer( new SpCustomerApi.CustomerSummary() { Name = string.Empty, ExternalId = anonymousExternalId } ); Assert.Equal( HttpStatusCode.BadRequest, response.StatusCode ); }
/// <summary> /// In the course of our testing, we need to be assured the changes actually get applied. /// In the standard programming model, it is safe to assume success once one has attained an HttpStatusCode.Accept on the PUT - in the rare case of conflicts, this will be detected and handled in the normal way. /// For the purposes of the test, we are actually prepared to hang around to double-check that they really do get applied. /// </summary> static void VerifyGetCustomerReflectsAcceptedChanges( SpCustomerApi api, SpCustomerApi.CustomerSummary customerData ) { Verify.EventuallyWithBackOff( () => { var apiResult = api.GetCustomer( customerData._links.self.href ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); apiResult.Data.AsSource().OfLikeness<SpCustomerApi.CustomerSummary>() .OmitAutoComparison() .WithDefaultEquality( x => x.ExternalId ) .WithDefaultEquality( x => x.Name ) .ShouldEqual( customerData ); } ); }
public static void ShouldUpdateCustomerLinkForWellKnownTestCustomer( [Frozen] SpIssueApi api, RandomLicenseFromListFixture license, SpCustomerApi customerApi ) { var licenseData = license.Selected; var customerData = customerApi.GetCustomerList( "$filter=Name eq Test" ).Data.results.Single(); var signedCustomerData = customerApi.GetCustomer( customerData._links.self.href ).Data; UpdateAndVerifyCustomerLink( api, licenseData, signedCustomerData ); }
public OrganizationCreateModel( SpCustomerApi.CustomerSummary customer ) { _embedded = new _Embedded { Customer = customer }; }
public static void LinkWellFormed( SpCustomerApi.Link link ) { Assert.NotNull( link ); Assert.NotNull( link.href ); Assert.NotEmpty( link.href ); }
public static void ShouldHaveAtLeastOneItem( SpCustomerApi api ) { var response = api.GetCustomerList(); Assert.Equal( HttpStatusCode.OK, response.StatusCode ); Assert.NotEmpty( response.Data.results ); }
public static void ShouldAlwaysBeAvailable( SpCustomerApi api ) { var response = api.GetCustomerList(); Assert.Equal( HttpStatusCode.OK, response.StatusCode ); }
static void UpdateAndVerifyCustomerLink( SpIssueApi api, SpIssueApi.License license, SpCustomerApi.CustomerSummary customer ) { var licenseCustomerAssignmentHref = license._links.customerAssignment.href; var apiResult = api.PutLicenseCustomerAssignment( licenseCustomerAssignmentHref, customer ); Assert.Equal( HttpStatusCode.Accepted, apiResult.StatusCode ); Verify.EventuallyWithBackOff( () => { var updated = api.GetLicense( license._links.self.href ); Assert.Equal( HttpStatusCode.OK, updated.StatusCode ); Assert.NotNull( updated.Data._links.customer ); var customerSelfLink = customer._links.self; Assert.Equal( customerSelfLink.href, updated.Data._links.customer.href, StringComparer.OrdinalIgnoreCase ); } ); }
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 ) ); }