public static void ShouldAllowCounting( SpPortalLicenseApi api ) { var apiResult = api.GetLicenses( "$inlinecount=allpages&$top=1" ); VerifyResponse( apiResult, shouldHaveCount: true ); Assert.True( apiResult.Data.__count > 1 ); Assert.Equal( 1, apiResult.Data.results.Count ); }
public RandomLicenseFromListFixture( SpPortalLicenseApi api ) { var apiResult = api.GetLicenses(); Assert.Equal( ResponseStatus.Completed, apiResult.ResponseStatus ); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); Assert.True( apiResult.Data.results.Any(), GetType().Name + " requires the target login to have at least one License" ); _randomItem = apiResult.Data.results.ElementAtRandom(); }
public static void ShouldAllowOrdering( SpPortalLicenseApi api ) { var apiResult = api.GetLicenses( "$orderby=ActivationKey+desc" ); var data = VerifyResponse( apiResult ); Assert.NotEmpty( data ); var ordered = data.OrderByDescending( x => x.ActivationKey ).ToArray(); Assert.Equal( ordered.AsEnumerable(), data.AsEnumerable() ); }
public static void ShouldAllowPaging( SpPortalLicenseApi api ) { var firstQuery = api.GetLicenses( "$skip=0&$top=1" ); var secondQuery = api.GetLicenses( "$skip=1&$top=1" ); SpPortalLicenseApi.License first = VerifyResponse( firstQuery ).Single(); SpPortalLicenseApi.License second = VerifyResponse( secondQuery ).Single(); Assert.NotNull( first ); Assert.NotNull( second ); Assert.NotEqual( first._links.self.href, second._links.self.href ); }
public static void ShouldRespondToUnsupportedQueriesWithBadRequestAndStatusDescription( SpPortalLicenseApi api ) { var expectedFailures = new Dictionary<string, string>() { {"$top=1001","The field Top must be between 1 and 1000."}, {"$top=NaN","The field Top must be between 1 and 1000."}, {"$top=","The Top field is required."}, // a specified query field must be provided {"$orderby=","The OrderBy field is required."} // a specified query field must be provided }; foreach ( var expectedFailure in expectedFailures ) { var invalidQueryResult = api.GetLicenses( expectedFailure.Key ); Assert.Equal( HttpStatusCode.BadRequest, invalidQueryResult.StatusCode ); Assert.Equal( expectedFailure.Value, invalidQueryResult.StatusDescription ); } }
static void VerifyPutEventuallyGetsApplied( IEnumerable<SpPortalLicenseApi.CustomerTag> expected, SpPortalLicenseApi api ) { var apiResponse = api.PutCustomerTags( expected ); Assert.Equal( HttpStatusCode.Accepted, apiResponse.StatusCode ); VerifyCollectionEventuallyGetsUpdatedTo( expected, api ); }
public static void ShouldYieldAccepted( [Frozen]SpPortalLicenseApi api, SpPortalLicenseApi.CustomerTag[] tags ) { var apiResponse = api.PutCustomerTags( tags ); Assert.Equal( HttpStatusCode.Accepted, apiResponse.StatusCode ); }
public static void ShouldHaveNonEmptyNames( SpPortalLicenseApi api ) { var response = api.GetCustomerTags(); Assert.Equal( HttpStatusCode.OK, response.StatusCode ); Assert.False( response.Data.results.Any( t => string.IsNullOrEmpty( t.Name ) ) ); }
public static void ShouldHaveNonEmptyIds( SpPortalLicenseApi api ) { var response = api.GetCustomerTags(); Assert.Equal( HttpStatusCode.OK, response.StatusCode ); Assert.DoesNotContain( Guid.Empty, response.Data.results.Select( t => t.Id ) ); }
public static void ShouldAlwaysBeAvailable( SpPortalLicenseApi api ) { var response = api.GetCustomerTags(); Assert.Equal( HttpStatusCode.OK, response.StatusCode ); }
public ExistingTagsFixture( SpPortalLicenseApi api, SpPortalLicenseApi.CustomerTag[] tags ) { Tags = tags; _api = api; var response = api.PutCustomerTags( tags ); Assert.Equal( HttpStatusCode.Accepted, response.StatusCode ); }
public static void IdEmptyShouldYieldBadRequest( SpPortalLicenseApi api, IFixture fixture ) { var badTag = fixture.Build<SpPortalLicenseApi.CustomerTag>().With( x => x.Id, Guid.Empty ).CreateAnonymous(); var response = api.PutCustomerTags( new[] { badTag } ); Assert.Equal( HttpStatusCode.BadRequest, response.StatusCode ); }
public static void TooLongShouldYieldBadRequest( SpPortalLicenseApi api, IFixture fixture ) { var badTag = fixture.Build<SpPortalLicenseApi.CustomerTag>().With( x => x.Name, new String( 'a', 101 ) ).CreateAnonymous(); var response = api.PutCustomerTags( new[] { badTag } ); Assert.Equal( HttpStatusCode.BadRequest, response.StatusCode ); }
static void VerifyCollectionEventuallyGetsUpdatedTo( IEnumerable<SpPortalLicenseApi.CustomerTag> expected, SpPortalLicenseApi api ) { Verify.EventuallyWithBackOff( () => { var apiResult = api.GetCustomerTags(); Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode ); Assert.Equal( expected.Select( x => Tuple.Create( x.Id, x.Name ) ).ToArray(), apiResult.Data.results.Select( x => Tuple.Create( x.Id, x.Name ) ).ToArray() ); } ); }
public static void ShouldYieldResults( SpPortalLicenseApi api ) { var apiResult = api.GetLicenses(); VerifyResponse( apiResult ); }