예제 #1
0
			public static void ShouldUpdateTags( [Frozen] SpPortalLicenseApi portalApi, RandomLicenseFromListFixture license, ExistingTagsFixture tags, IFixture fixture )
			{
				var valuesForEachDefinedTag = tags.Tags
					.Select( ct => fixture.Build<SpPortalLicenseApi.LicenseTag>().With( x => x.Id, ct.Id ).CreateAnonymous() )
					.ToList();

				var licenseTagsAssignmentHref = license.Selected._embedded.CustomerTags._links.self.href;
				var apiResult = portalApi.PutLicenseTags( licenseTagsAssignmentHref, valuesForEachDefinedTag );
				Assert.Equal( ResponseStatus.Completed, apiResult.ResponseStatus );
				Assert.Equal( HttpStatusCode.Accepted, apiResult.StatusCode );

				Verify.EventuallyWithBackOff( () =>
				{
					//Retrieve the license again (if it was supported, just GETting the tags subresource would be sufficient to prove the point)
					var updatedLicense = portalApi.GetLicense( license.Selected._links.self.href );

					//Verify that all the tags on the license match
					Assert.Equal( ResponseStatus.Completed, updatedLicense.ResponseStatus );
					Assert.NotNull( updatedLicense.Data._embedded.CustomerTags.results );
					Assert.NotEmpty( updatedLicense.Data._embedded.CustomerTags.results );
					// TOOD use xUnit 1.9 and/or Ploeh.semanticComparison to make this cleaner
					Assert.Equal(
						updatedLicense.Data._embedded.CustomerTags.results.OrderBy( x => x.Id ).Select( x => Tuple.Create( x.Id, x.Value ) ).ToArray(),
						valuesForEachDefinedTag.OrderBy( x => x.Id ).Select( x => Tuple.Create( x.Id, x.Value ) ).ToArray() );
				} );
			}
예제 #2
0
				public static void TooLongValuesShouldBeRejected( [Frozen] SpPortalLicenseApi portalApi, RandomLicenseFromListFixture license, ExistingTagsFixture tags, IFixture fixture )
				{
					var validTagWithValueThatIsTooLong = GenerateLicenseTag( new String( 'a', 101 ), tags );

					var licenseTagsAssignmentHref = license.Selected._embedded.CustomerTags._links.self.href;
					var apiResult = portalApi.PutLicenseTags( licenseTagsAssignmentHref, validTagWithValueThatIsTooLong );
					Assert.Equal( ResponseStatus.Completed, apiResult.ResponseStatus );
					Assert.Equal( HttpStatusCode.BadRequest, apiResult.StatusCode );
				}
예제 #3
0
				static SpPortalLicenseApi.LicenseTag[] GenerateLicenseTag( string value, ExistingTagsFixture tags )
				{
					return tags.Tags
						.Select( ct => new Fixture().Build<SpPortalLicenseApi.LicenseTag>()
							.With( x => x.Id, ct.Id )
							.With( x => x.Value, value )
							.CreateAnonymous() )
						.Take( 1 )
						.ToArray();
				}
예제 #4
0
					public static void ShouldEventuallyBeVisible( [Frozen]SpPortalLicenseApi api, ExistingTagsFixture tags )
					{
						var updated = tags.Tags.Where( ( x, index ) => index != 1 );
						VerifyPutEventuallyGetsApplied( updated, api );
					}
예제 #5
0
					public static void ShouldEventuallyBeVisible( [Frozen]SpPortalLicenseApi api, ExistingTagsFixture tags )
					{
						var updated = tags.Tags.Select( x => new SpPortalLicenseApi.CustomerTag { Id = x.Id, Name = x.Name + "renamed" } );
						VerifyPutEventuallyGetsApplied( updated, api );
					}
예제 #6
0
				public static void ShouldEventuallyBeVisible( [Frozen]SpPortalLicenseApi api, ExistingTagsFixture tags )
				{
					VerifyCollectionEventuallyGetsUpdatedTo( tags.Tags, api );
				}
예제 #7
0
                public static void DuplicateValuesShouldBeRejected( [Frozen] SpPortalLicenseApi portalApi, RandomLicenseFromListFixture license, ExistingTagsFixture tags, IFixture fixture )
				{
					var validTagValue = tags.Tags
						.Select( ct => fixture.Build<SpPortalLicenseApi.LicenseTag>()
							.With( x => x.Id, ct.Id )
							.CreateAnonymous() )
						.Take( 1 )
						.ToArray();

					var theSameValueTwice = validTagValue.Concat( validTagValue ).ToArray();

					var licenseTagsAssignmentHref = license.Selected._embedded.CustomerTags._links.self.href;
					var apiResult = portalApi.PutLicenseTags( licenseTagsAssignmentHref, theSameValueTwice );
					Assert.Equal( ResponseStatus.Completed, apiResult.ResponseStatus );
					Assert.Equal( HttpStatusCode.InternalServerError, apiResult.StatusCode );
				}