Exemple #1
0
            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();
		}
Exemple #3
0
            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() );
            }
Exemple #4
0
            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 );
            }
Exemple #5
0
            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 );
                }
            }
Exemple #6
0
				static void VerifyPutEventuallyGetsApplied( IEnumerable<SpPortalLicenseApi.CustomerTag> expected, SpPortalLicenseApi api )
				{
					var apiResponse = api.PutCustomerTags( expected );
					Assert.Equal( HttpStatusCode.Accepted, apiResponse.StatusCode );
					VerifyCollectionEventuallyGetsUpdatedTo( expected, api );
				}
Exemple #7
0
				public static void ShouldYieldAccepted( [Frozen]SpPortalLicenseApi api, SpPortalLicenseApi.CustomerTag[] tags )
				{
					var apiResponse = api.PutCustomerTags( tags );
					Assert.Equal( HttpStatusCode.Accepted, apiResponse.StatusCode );
				}
Exemple #8
0
				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 ) ) );
				}
Exemple #9
0
				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 ) );
				}
Exemple #10
0
				public static void ShouldAlwaysBeAvailable( SpPortalLicenseApi api )
				{
					var response = api.GetCustomerTags();
					Assert.Equal( HttpStatusCode.OK, response.StatusCode );
				}
Exemple #11
0
		public ExistingTagsFixture( SpPortalLicenseApi api, SpPortalLicenseApi.CustomerTag[] tags )
		{
			Tags = tags;
			_api = api;
			var response = api.PutCustomerTags( tags );
			Assert.Equal( HttpStatusCode.Accepted, response.StatusCode );
		}
Exemple #12
0
					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 );
					}
Exemple #13
0
					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 );
					}
Exemple #14
0
				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() );
					} );
				}
Exemple #15
0
            public static void ShouldYieldResults( SpPortalLicenseApi api )
            {
                var apiResult = api.GetLicenses();

                VerifyResponse( apiResult );
            }