/// <summary> /// Adds an assertion to the specified fixture that the JSON result will be equivalent to the specified model. /// </summary> /// <typeparam name="TResponseModel">The type of the response model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam> /// <param name="fixture">The fixture.</param> /// <param name="models">The models.</param> /// <param name="options">The options.</param> /// <returns></returns> public static IMvcFunctionalTestFixture ShouldReturnJsonCollectionContainingEquivalentModels <TResponseModel, TModel>( this IMvcFunctionalTestFixture fixture, ICollection <TModel> models, Func <EquivalencyAssertionOptions <TModel>, EquivalencyAssertionOptions <TModel> > options = null) => fixture.ShouldReturnJson(models.Select <TModel, Action <ICollection <TResponseModel> > >(e => x => x.Should().ContainEquivalentOf(e, options ?? (c => c))) .ToArray());
/// <summary> /// Adds an assertion to the specified fixture that the JSON result returned will be a collection of the specified length. /// </summary> /// <param name="fixture">The fixture.</param> /// <param name="count">The count.</param> /// <returns></returns> public static IMvcFunctionalTestFixture ShouldReturnCollectionOfLength(this IMvcFunctionalTestFixture fixture, int count) => fixture.ShouldReturnJson <ICollection <object> >(x => x.Should().HaveCount(count));
/// <summary> /// Adds an assertion to the specified fixture that the JSON result returned will be an empty collection. /// </summary> /// <param name="fixture">The fixture.</param> /// <returns></returns> public static IMvcFunctionalTestFixture ShouldReturnEmptyCollection(this IMvcFunctionalTestFixture fixture) => fixture.ShouldReturnJson <ICollection <object> >(x => x.Should().BeEmpty());
/// <summary> /// Adds an assertion to the specified fixture that the JSON result will be equivalent to the specified model. /// </summary> /// <typeparam name="TResponseModel">The type of the response model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam> /// <param name="fixture">The fixture.</param> /// <param name="model">The model.</param> /// <returns></returns> public static IMvcFunctionalTestFixture ShouldReturnEquivalentResponse <TResponseModel, TModel>(this IMvcFunctionalTestFixture fixture, TModel model) => fixture.ShouldReturnJson <TResponseModel>(x => x.Should().BeEquivalentTo(model));
/// <summary> /// Adds an assertion to the specified fixture that the JSON result will be equivalent to the specified model. /// </summary> /// <typeparam name="TResponseModel">The type of the response model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam> /// <param name="fixture">The fixture.</param> /// <param name="model">The model.</param> /// <param name="options">The options.</param> /// <returns></returns> public static IMvcFunctionalTestFixture ShouldReturnJsonCollectionContainingEquivalentModel <TResponseModel, TModel>( this IMvcFunctionalTestFixture fixture, TModel model, Func <EquivalencyAssertionOptions <TModel>, EquivalencyAssertionOptions <TModel> > options = null) => fixture.ShouldReturnJson <ICollection <TResponseModel> >(x => x.Should().ContainEquivalentOf(model, options ?? (c => c)));
/// <summary> /// Adds an assertion to the specified fixture that the JSON result will be equivalent to the specified model. /// </summary> /// <typeparam name="TResponseModel">The type of the response model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam> /// <param name="fixture">The fixture.</param> /// <param name="model">The model.</param> /// <param name="options">The equivalency assertion options.</param> /// <returns></returns> public static IMvcFunctionalTestFixture ShouldReturnEquivalentJson <TResponseModel, TModel>( this IMvcFunctionalTestFixture fixture, TModel model, Func <EquivalencyAssertionOptions <TModel>, EquivalencyAssertionOptions <TModel> > options = null) => fixture.ShouldReturnJson <TResponseModel>(x => x.Should().BeEquivalentTo(model, options ?? (c => c)));
public static IMvcFunctionalTestFixture ShouldReturnBreakfastItems(this IMvcFunctionalTestFixture fixture, ICollection <BreakfastItem> expected) => fixture.ShouldReturnJson <ICollection <BreakfastItem> >(rs => rs.Should() .HaveSameCount(expected) .And.HaveEquivalentProperty(expected, x => x.Id) .And.HaveEquivalentProperty(expected, x => x.Name) .And.HaveEquivalentProperty(expected, x => x.Rating));
public static IMvcFunctionalTestFixture ShouldReturnBreakfastItem(this IMvcFunctionalTestFixture fixture, BreakfastItem expected) => fixture.ShouldReturnJson <BreakfastItem>(r => r.Id.Should().Be(expected.Id), r => r.Name.Should().Be(expected.Name), r => r.Rating.Should().Be(expected.Rating));