public static void UnmodifiedShouldYieldAccepted( [Frozen] SpCustomerApi api, IFixture fixture ) { HandleTightLoopEdgeCase( () => fixture.Do( ( GetRandomCustomerFixture customer ) => { SpCustomerApi.CustomerSummary customerData = customer.DataFromGet; var apiResult = api.PutCustomer( customerData._links.self.href, customerData ); Assert.Equal( HttpStatusCode.Accepted, apiResult.StatusCode ); } ) ); }
public static void ModifiedShouldYieldAccepted( [Frozen] SpCustomerApi api, string anonymousName, string anonymousExternalId, IFixture fixture ) { var customerData = default( SpCustomerApi.CustomerSummary ); HandleTightLoopEdgeCase( () => fixture.Do( ( GetRandomCustomerFixture customer ) => { customerData = customer.DataFromGet; customerData.Name = anonymousName; customerData.ExternalId = anonymousExternalId; var apiResult = api.PutCustomer( customerData._links.self.href, customerData ); Assert.Equal( HttpStatusCode.Accepted, apiResult.StatusCode ); } ) ); VerifyGetCustomerReflectsAcceptedChanges( api, customerData ); }
public static void NonMatchingChangesShouldYieldConflict( [Frozen] SpCustomerApi api, string anonymousName1, string anonymousExternalId1, string anonymousName2, string anonymousExternalId2, IFixture fixture ) { var customerData = default( SpCustomerApi.CustomerSummary ); HandleTightLoopEdgeCase( () => fixture.Do( ( GetRandomCustomerFixture customer ) => { customerData = customer.DataFromGet; customerData.Name = anonymousName1; customerData.ExternalId = anonymousExternalId1; var firstResult = api.PutCustomer( customerData._links.self.href, customerData ); Assert.Equal( HttpStatusCode.Accepted, firstResult.StatusCode ); } ) ); customerData.Name = anonymousName2; customerData.ExternalId = anonymousExternalId2; var apiResult = api.PutCustomer( customerData._links.self.href, customerData ); Assert.Equal( HttpStatusCode.Conflict, apiResult.StatusCode ); // Our second edits should not have been applied, so revert customerData.Name = anonymousName1; customerData.ExternalId = anonymousExternalId1; VerifyGetCustomerReflectsAcceptedChanges( api, customerData ); }