/// <summary> /// Tests whether the component does not set any <see cref="Microsoft.AspNetCore.Http.ISession"/> entries. /// </summary> /// <typeparam name="TBuilder">Class representing ASP.NET Core MVC test builder.</typeparam> /// <param name="builder">Instance of <see cref="IBaseTestBuilderWithComponentShouldHaveTestBuilder{TBuilder}"/> type.</param> /// <returns>The same component should have test builder.</returns> public static TBuilder NoSession <TBuilder>(this IBaseTestBuilderWithComponentShouldHaveTestBuilder <TBuilder> builder) where TBuilder : IBaseTestBuilder { var actualBuilder = (BaseTestBuilderWithComponentBuilder <TBuilder>)builder; if (actualBuilder.TestContext.Session.Keys.Any()) { DataProviderValidator.ThrowNewDataProviderAssertionExceptionWithNoEntries( actualBuilder.TestContext, SessionTestBuilder.SessionName); } return(actualBuilder.Builder); }
/// <summary> /// Tests whether the component does not set any <see cref="Microsoft.Extensions.Caching.Distributed.IDistributedCache"/> entries. /// </summary> /// <typeparam name="TBuilder">Class representing ASP.NET Core MVC test builder.</typeparam> /// <param name="builder">Instance of <see cref="IBaseTestBuilderWithComponentShouldHaveTestBuilder{TBuilder}"/> type.</param> /// <returns>The same component should have test builder.</returns> public static TBuilder NoDistributedCache <TBuilder>(this IBaseTestBuilderWithComponentShouldHaveTestBuilder <TBuilder> builder) where TBuilder : IBaseTestBuilder { var actualBuilder = (BaseTestBuilderWithComponentBuilder <TBuilder>)builder; if (actualBuilder.TestContext.GetDistributedCacheMock().Count > 0) { DataProviderValidator.ThrowNewDataProviderAssertionExceptionWithNoEntries( actualBuilder.TestContext, DistributedCacheTestBuilder.DistributedCacheName); } return(actualBuilder.Builder); }
/// <summary> /// Tests whether the component does not set any dynamic view bag entries. /// </summary> /// <typeparam name="TBuilder">Class representing ASP.NET Core MVC test builder.</typeparam> /// <param name="builder">Instance of <see cref="IBaseTestBuilderWithComponentShouldHaveTestBuilder{TBuilder}"/> type.</param> /// <returns>The same component should have test builder.</returns> public static TBuilder NoViewBag <TBuilder>(this IBaseTestBuilderWithComponentShouldHaveTestBuilder <TBuilder> builder) where TBuilder : IBaseTestBuilder { var actualBuilder = (BaseTestBuilderWithComponentBuilder <TBuilder>)builder; if (actualBuilder.TestContext.GetViewData().Count > 0) { DataProviderValidator.ThrowNewDataProviderAssertionExceptionWithNoEntries( actualBuilder.TestContext, ViewBagTestBuilder.ViewBagName); } return(actualBuilder.Builder); }