Skip to content

Commit 0a9d4fe

Browse files
committed
#283 WIthoutTempData class naming refactoring, adding the class shells without the implementation.
1 parent 32cd5df commit 0a9d4fe

8 files changed

Lines changed: 102 additions & 26 deletions

src/MyTested.AspNetCore.Mvc.TempData/Builders/Contracts/Data/IAndTempDataBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.TempData/Builders/Contracts/Data/IAndWithTempDataBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
/// <summary>
44
/// Used for adding AndAlso() method to the <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/> builder.
55
/// </summary>
6-
public interface IAndTempDataBuilder : ITempDataBuilder
6+
public interface IAndWithTempDataBuilder : IWithTempDataBuilder
77
{
88
/// <summary>
99
/// AndAlso method for better readability when building <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.
1010
/// </summary>
11-
/// <returns>The same <see cref="ITempDataBuilder"/>.</returns>
12-
ITempDataBuilder AndAlso();
11+
/// <returns>The same <see cref="IWithTempDataBuilder"/>.</returns>
12+
IWithTempDataBuilder AndAlso();
1313
}
1414
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Data
2+
{
3+
public interface IAndWithoutTempDataBuilder : IWithoutTempDataBuilder
4+
{
5+
IWithoutTempDataBuilder AndAlso();
6+
}
7+
}

src/MyTested.AspNetCore.Mvc.TempData/Builders/Contracts/Data/ITempDataBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.TempData/Builders/Contracts/Data/IWithTempDataBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55
/// <summary>
66
/// Used for building <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.
77
/// </summary>
8-
public interface ITempDataBuilder
8+
public interface IWithTempDataBuilder
99
{
1010
/// <summary>
1111
/// Adds temp data entry to the built <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.
1212
/// </summary>
1313
/// <param name="key">Key of the temp data entry.</param>
1414
/// <param name="value">Value of the temp data entry.</param>
1515
/// <returns>The same <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.</returns>
16-
IAndTempDataBuilder WithEntry(string key, object value);
16+
IAndWithTempDataBuilder WithEntry(string key, object value);
1717

1818
/// <summary>
1919
/// Adds temp data entries to the built <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.
2020
/// </summary>
2121
/// <param name="entries">Dictionary of temp data entries.</param>
2222
/// <returns>The same <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.</returns>
23-
IAndTempDataBuilder WithEntries(IDictionary<string, object> entries);
23+
IAndWithTempDataBuilder WithEntries(IDictionary<string, object> entries);
2424

2525
/// <summary>
2626
/// Adds temp data entries to the built <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.
2727
/// </summary>
2828
/// <param name="entries">Anonymous object of temp data entries.</param>
2929
/// <returns>The same <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary"/>.</returns>
30-
IAndTempDataBuilder WithEntries(object entries);
30+
IAndWithTempDataBuilder WithEntries(object entries);
3131
}
3232
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
3+
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Data
4+
{
5+
public interface IWithoutTempDataBuilder
6+
{
7+
IAndWithoutTempDataBuilder WithEntry(string key, object value);
8+
9+
IAndWithoutTempDataBuilder WithEntries(IDictionary<string, object> entries);
10+
11+
IAndWithoutTempDataBuilder WithEntries(object entries);
12+
13+
IAndWithoutTempDataBuilder WithoutAllEntries();
14+
}
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace MyTested.AspNetCore.Mvc.Builders.Data
2+
{
3+
using Microsoft.AspNetCore.Mvc.ViewFeatures;
4+
using MyTested.AspNetCore.Mvc.Utilities.Validators;
5+
6+
public abstract class BaseTempDataBuilder
7+
{
8+
public BaseTempDataBuilder(ITempDataDictionary tempData)
9+
{
10+
CommonValidator.CheckForNullReference(tempData, nameof(ITempDataDictionary));
11+
this.TempData = tempData;
12+
}
13+
14+
/// <summary>
15+
/// Gets the mocked <see cref="ITempDataDictionary"/>.
16+
/// </summary>
17+
/// <value>Built <see cref="ITempDataDictionary"/>.</value>
18+
protected ITempDataDictionary TempData { get; private set; }
19+
}
20+
}

src/MyTested.AspNetCore.Mvc.TempData/Builders/Data/TempDataBuilder.cs renamed to src/MyTested.AspNetCore.Mvc.TempData/Builders/Data/WithTempDataBuilder.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,36 @@
1010
/// <summary>
1111
/// Used for building mocked <see cref="ITempDataDictionary"/>.
1212
/// </summary>
13-
public class TempDataBuilder : IAndTempDataBuilder
13+
public class WithTempDataBuilder : BaseTempDataBuilder, IAndWithTempDataBuilder
1414
{
1515
/// <summary>
16-
/// Initializes a new instance of the <see cref="TempDataBuilder"/> class.
16+
/// Initializes a new instance of the <see cref="WithTempDataBuilder"/> class.
1717
/// </summary>
1818
/// <param name="tempData"><see cref="ITempDataDictionary"/> to built.</param>
19-
public TempDataBuilder(ITempDataDictionary tempData)
19+
public WithTempDataBuilder(ITempDataDictionary tempData)
20+
: base(tempData)
2021
{
21-
CommonValidator.CheckForNullReference(tempData, nameof(ITempDataDictionary));
22-
this.TempData = tempData;
2322
}
2423

25-
/// <summary>
26-
/// Gets the mocked <see cref="ITempDataDictionary"/>.
27-
/// </summary>
28-
/// <value>Built <see cref="ITempDataDictionary"/>.</value>
29-
protected ITempDataDictionary TempData { get; private set; }
30-
3124
/// <inheritdoc />
32-
public IAndTempDataBuilder WithEntry(string key, object value)
25+
public IAndWithTempDataBuilder WithEntry(string key, object value)
3326
{
3427
this.TempData.Add(key, value);
3528
return this;
3629
}
3730

3831
/// <inheritdoc />
39-
public IAndTempDataBuilder WithEntries(IDictionary<string, object> entries)
32+
public IAndWithTempDataBuilder WithEntries(IDictionary<string, object> entries)
4033
{
4134
entries.ForEach(e => this.WithEntry(e.Key, e.Value));
4235
return this;
4336
}
4437

4538
/// <inheritdoc />
46-
public IAndTempDataBuilder WithEntries(object entries)
39+
public IAndWithTempDataBuilder WithEntries(object entries)
4740
=> this.WithEntries(new RouteValueDictionary(entries));
4841

4942
/// <inheritdoc />
50-
public ITempDataBuilder AndAlso() => this;
43+
public IWithTempDataBuilder AndAlso() => this;
5144
}
5245
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+

2+
namespace MyTested.AspNetCore.Mvc.Builders.Data
3+
{
4+
using System;
5+
using System.Collections.Generic;
6+
using Microsoft.AspNetCore.Mvc.ViewFeatures;
7+
using MyTested.AspNetCore.Mvc.Builders.Contracts.Data;
8+
9+
public class WithoutTempDataBuilder : BaseTempDataBuilder, IAndWithoutTempDataBuilder
10+
{
11+
public WithoutTempDataBuilder(ITempDataDictionary tempData)
12+
: base(tempData)
13+
{
14+
}
15+
16+
public IWithoutTempDataBuilder AndAlso()
17+
{
18+
throw new NotImplementedException();
19+
}
20+
21+
public IAndWithoutTempDataBuilder WithEntries(IDictionary<string, object> entries)
22+
{
23+
throw new NotImplementedException();
24+
}
25+
26+
public IAndWithoutTempDataBuilder WithEntries(object entries)
27+
{
28+
throw new NotImplementedException();
29+
}
30+
31+
public IAndWithoutTempDataBuilder WithEntry(string key, object value)
32+
{
33+
throw new NotImplementedException();
34+
}
35+
36+
public IAndWithoutTempDataBuilder WithoutAllEntries()
37+
{
38+
throw new NotImplementedException();
39+
}
40+
}
41+
}

src/MyTested.AspNetCore.Mvc.TempData/ComponentBuilderTempDataExtensions.cs renamed to src/MyTested.AspNetCore.Mvc.TempData/ComponentBuilderTempDataWithExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
/// <summary>
1111
/// Contains <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.TempDataDictionary"/> extension methods for <see cref="IBaseTestBuilderWithComponentBuilder{TBuilder}"/>.
1212
/// </summary>
13-
public static class ComponentBuilderTempDataExtensions
13+
public static class ComponentBuilderTempDataWithExtensions
1414
{
1515
/// <summary>
1616
/// Sets initial values to the <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.TempDataDictionary"/> on the tested component.
1717
/// </summary>
1818
/// <typeparam name="TBuilder">Class representing ASP.NET Core MVC test builder.</typeparam>
1919
/// <param name="builder">Instance of <see cref="IBaseTestBuilderWithComponentBuilder{TBuilder}"/> type.</param>
20-
/// <param name="tempDataBuilder">Action setting the <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.TempDataDictionary"/> values by using <see cref="ITempDataBuilder"/>.</param>
20+
/// <param name="tempDataBuilder">Action setting the <see cref="Microsoft.AspNetCore.Mvc.ViewFeatures.TempDataDictionary"/> values by using <see cref="IWithTempDataBuilder"/>.</param>
2121
/// <returns>The same component builder.</returns>
2222
public static TBuilder WithTempData<TBuilder>(
2323
this IBaseTestBuilderWithComponentBuilder<TBuilder> builder,
24-
Action<ITempDataBuilder> tempDataBuilder)
24+
Action<IWithTempDataBuilder> tempDataBuilder)
2525
where TBuilder : IBaseTestBuilder
2626
{
2727
var actualBuilder = (BaseTestBuilderWithComponentBuilder<TBuilder>)builder;
2828

2929
actualBuilder.TestContext.ComponentPreparationDelegate += () =>
3030
{
31-
tempDataBuilder(new TempDataBuilder(actualBuilder.TestContext.GetTempData()));
31+
tempDataBuilder(new WithTempDataBuilder(actualBuilder.TestContext.GetTempData()));
3232
};
3333

3434
return actualBuilder.Builder;

0 commit comments

Comments
 (0)