Example #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() );
				} );
			}
Example #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 );
				}
Example #3
0
 public static void ShouldIncludeLicenseTagsAssignmentLink( RandomLicenseFromListFixture license )
 {
     Assert.NotNull( license.Selected._embedded.CustomerTags._links.self );
     Assert.NotEmpty( license.Selected._embedded.CustomerTags._links.self.href );
 }
Example #4
0
 public static void ShouldIncludeSelfLink( RandomLicenseFromListFixture license )
 {
     Assert.NotNull( license.Selected._links.self );
     Assert.NotEmpty( license.Selected._links.self.href );
 }
Example #5
0
 public static void ShouldContainData( RandomLicenseFromListFixture license )
 {
     // There should always be valid Activation Key
     Assert.NotEmpty( license.Selected.ActivationKey );
     // There should always be a Product Label
     Assert.NotEmpty( license.Selected.ProductLabel );
     // There should always be a Version Label
     Assert.NotEmpty( license.Selected.VersionLabel );
     // There is always an IssueDate
     Assert.NotEmpty( license.Selected.IssueDate );
     // There are always embedded CustomerTags (even if no explicit $expand is specified)
     Assert.NotNull( license.Selected._embedded.CustomerTags );
     // There is always a list - it might be empty though
     Assert.NotNull( license.Selected._embedded.CustomerTags.results );
 }
Example #6
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 );
				}