Exemplo n.º 1
0
			public static void GetNonExistingProductShould404( [Frozen] SpDefineApi api, RandomProductFromListFixture product, Guid anonymousId )
			{
				string validHref = product.SelectedProduct._links.self.href;
				string invalidHref = UriHelper.HackLinkReplacingGuidWithAlternateValue( anonymousId, validHref );
				var apiResult = api.GetProduct( invalidHref );
				// We don't want to have landed on an error page that has a StatusCode of 200
				Assert.Equal( HttpStatusCode.NotFound, apiResult.StatusCode );
				// Our final Location should match what we asked for
				Assert.Contains( invalidHref.ToString(), apiResult.ResponseUri.ToString() );
			}
Exemplo n.º 2
0
			public static void GetProductFromListShouldYieldData( [Frozen] SpDefineApi api, RandomProductFromListFixture product )
			{
				var linkedAddress = product.SelectedProduct._links.self.href;
				var apiResult = api.GetProduct( linkedAddress );
				// It should always be possible to get the data
				Assert.Equal( HttpStatusCode.OK, apiResult.StatusCode );
				// Our final Location should match what we asked for (i.e., we don't want to have landed on an error page that has a StatusCode of 200)
				Assert.Contains( linkedAddress.ToString(), apiResult.ResponseUri.ToString() );
				// There should always be valid Data
				Assert.NotNull( apiResult.Data );
				// There should always be a reference
				Assert.NotEmpty( apiResult.Data.ReferenceId );
				// There should always be a label
				Assert.NotEmpty( apiResult.Data.Label );
			}
Exemplo n.º 3
0
				public static void GetNonGuidProductShould400( [Frozen] SpDefineApi api, RandomProductFromListFixture product )
				{
					string misformattedHackedHref = product.SelectedProduct._links.self.href + "broken";
					var apiResult = api.GetProduct( misformattedHackedHref );
					// TODO move this after the next assert when this one starts passing
					// Our final Location should match what we asked for (i.e., we don't want to have landed on an error page that has a StatusCode of 200)
					Assert.Contains( misformattedHackedHref, apiResult.ResponseUri.ToString() );
					// We should know there's a problem
					Assert.Equal( HttpStatusCode.BadRequest, apiResult.StatusCode );
					// No data should be yielded
					Assert.Null( apiResult.Data );
				}
Exemplo n.º 4
0
					public static void PutExcessivelyLongDescriptionShouldReject( [Frozen] SpDefineApi api, RandomProductFromListFixture product )
					{
						product.SelectedProduct.Description = new String( 'a', 101 );
						Assert.Equal( HttpStatusCode.BadRequest, product.PutSelectedProduct().StatusCode );
					}
Exemplo n.º 5
0
					public static void PutNullDescriptionShouldReject( [Frozen] SpDefineApi api, RandomProductFromListFixture product )
					{
						product.SelectedProduct.Description = null;
						Assert.Equal( HttpStatusCode.BadRequest, product.PutSelectedProduct().StatusCode );
					}
Exemplo n.º 6
0
					public static void PutEmptyShouldReject( [Frozen] SpDefineApi api, RandomProductFromListFixture product )
					{
						product.SelectedProduct.Label = string.Empty;
						Assert.Equal( HttpStatusCode.BadRequest, product.PutSelectedProduct().StatusCode );
					}
Exemplo n.º 7
0
			public static void PutProductFromListWithUpdatedLabelShouldRoundtrip( [Frozen] SpDefineApi api, RandomProductFromListFixture product, string updatedValue )
			{
				product.SelectedProduct.Label = updatedValue;

				Assert.Equal( HttpStatusCode.OK, product.PutSelectedProduct().StatusCode );

				Verify.EventuallyWithBackOff( () =>
					Assert.Equal( updatedValue, product.GetSelectedProductAgain().Label ) );
			}