|
| 1 | +namespace MyTested.AspNetCore.Mvc |
| 2 | +{ |
| 3 | + using System; |
| 4 | + using System.Collections.Generic; |
| 5 | + using Builders.Contracts.Base; |
| 6 | + using Builders.Contracts.Data; |
| 7 | + using Builders.Base; |
| 8 | + using Builders.Data; |
| 9 | + using Internal.TestContexts; |
| 10 | + |
| 11 | + public static class ComponentBuilderTempDataWithoutExtensions |
| 12 | + { |
| 13 | + public static TBuilder WithoutTempData<TBuilder>( |
| 14 | + this IBaseTestBuilderWithComponentBuilder<TBuilder> builder, |
| 15 | + string key) |
| 16 | + where TBuilder : IBaseTestBuilder |
| 17 | + => builder.WithoutTempData(tempData => tempData.WithoutEntry(key)); |
| 18 | + |
| 19 | + public static TBuilder WithoutTempData<TBuilder>( |
| 20 | + this IBaseTestBuilderWithComponentBuilder<TBuilder> builder, |
| 21 | + params string[] keys) |
| 22 | + where TBuilder : IBaseTestBuilder |
| 23 | + => builder.WithoutTempData(tempData => tempData.WithoutEntries(keys)); |
| 24 | + |
| 25 | + public static TBuilder WithoutTempData<TBuilder>( |
| 26 | + this IBaseTestBuilderWithComponentBuilder<TBuilder> builder, |
| 27 | + IEnumerable<string> keys) |
| 28 | + where TBuilder : IBaseTestBuilder |
| 29 | + => builder.WithoutTempData(tempData => tempData.WithoutEntries(keys)); |
| 30 | + |
| 31 | + public static TBuilder WithoutTempData<TBuilder>( |
| 32 | + this IBaseTestBuilderWithComponentBuilder<TBuilder> builder) |
| 33 | + where TBuilder : IBaseTestBuilder |
| 34 | + => builder.WithoutTempData(tempData => tempData.WithoutAllEntries()); |
| 35 | + |
| 36 | + public static TBuilder WithoutTempData<TBuilder>( |
| 37 | + this IBaseTestBuilderWithComponentBuilder<TBuilder> builder, |
| 38 | + Action<IWithoutTempDataBuilder> tempDataBuilder) |
| 39 | + where TBuilder : IBaseTestBuilder |
| 40 | + { |
| 41 | + var actualBuilder = (BaseTestBuilderWithComponentBuilder<TBuilder>)builder; |
| 42 | + |
| 43 | + actualBuilder.TestContext.ComponentPreparationDelegate += () => |
| 44 | + { |
| 45 | + tempDataBuilder(new WithoutTempDataBuilder(actualBuilder.TestContext.GetTempData())); |
| 46 | + }; |
| 47 | + |
| 48 | + return actualBuilder.Builder; |
| 49 | + } |
| 50 | + } |
| 51 | +} |
0 commit comments