예제 #1
0
			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;
			}
예제 #2
0
		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;
		}
예제 #4
0
		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;
		}
예제 #8
0
			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;
				} );
			}
예제 #9
0
				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 );
				}
예제 #10
0
				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 );
				}
예제 #11
0
		/// <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 );
			} );
		}
예제 #12
0
				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 );
				}
예제 #13
0
			public OrganizationCreateModel( SpCustomerApi.CustomerSummary customer )
			{
				_embedded = new _Embedded { Customer = customer };
			}
예제 #14
0
		public static void LinkWellFormed( SpCustomerApi.Link link )
		{
			Assert.NotNull( link );
			Assert.NotNull( link.href );
			Assert.NotEmpty( link.href );
		}
예제 #15
0
		public static void ShouldHaveAtLeastOneItem( SpCustomerApi api )
		{
			var response = api.GetCustomerList();
			Assert.Equal( HttpStatusCode.OK, response.StatusCode );
			Assert.NotEmpty( response.Data.results );
		}
예제 #16
0
		public static void ShouldAlwaysBeAvailable( SpCustomerApi api )
		{
			var response = api.GetCustomerList();
			Assert.Equal( HttpStatusCode.OK, response.StatusCode );
		}
예제 #17
0
				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 );
					} );
				}
예제 #18
0
		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 ) );
		}