Skip to content

Commit 3235f86

Browse files
committed
#283 Adding comments for the public methods and classes in WithoutCache components.
1 parent c3c4637 commit 3235f86

File tree

6 files changed

+70
-3
lines changed

6 files changed

+70
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Data
22
{
3+
/// <summary>
4+
/// Used for adding AndAlso() method to the <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/> builder.
5+
/// </summary>
36
public interface IAndWithoutMemoryCacheBuilder : IWithoutMemoryCacheBuilder
47
{
8+
/// <summary>
9+
/// AndAlso method for better readability when building <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/>.
10+
/// </summary>
11+
/// <returns>The same <see cref="IWithoutMemoryCacheBuilder"/>.</returns>
512
IWithoutMemoryCacheBuilder AndAlso();
613
}
714
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Data
22
{
3+
using Microsoft.Extensions.Caching.Memory;
34
using System.Collections.Generic;
45

6+
/// <summary>
7+
/// Used for building mocked <see cref="IMemoryCache"/>.
8+
/// </summary>
59
public interface IWithoutMemoryCacheBuilder
610
{
11+
/// <summary>
12+
/// Remove cache entry to the mocked <see cref="IMemoryCache"/>.
13+
/// </summary>
14+
/// <param name="key">Key of the cache entry.</param>
15+
/// <returns>The same <see cref="IAndWithoutMemoryCacheBuilder"/>.</returns>
716
IAndWithoutMemoryCacheBuilder WithoutEntry(object key);
817

18+
/// <summary>
19+
/// Remove cache entries to the mocked <see cref="IMemoryCache"/>.
20+
/// </summary>
21+
/// <param name="keys">Keys of the cache entries.</param>
22+
/// <returns>The same <see cref="IAndWithoutMemoryCacheBuilder"/>.</returns>
923
IAndWithoutMemoryCacheBuilder WithoutEntries(IEnumerable<object> keys);
1024

25+
/// <summary>
26+
/// Clear all entries persisted into the <see cref="IMemoryCache"/>.
27+
/// </summary>
28+
/// <returns>The same <see cref="IAndWithoutMemoryCacheBuilder"/>.</returns>
1129
IAndWithoutMemoryCacheBuilder ClearCache();
1230
}
1331
}

src/MyTested.AspNetCore.Mvc.Caching/Builders/Data/MemoryCacheBaseBuilder.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44
using Microsoft.Extensions.DependencyInjection;
55
using System;
66

7+
/// <summary>
8+
/// Used for building mocked <see cref="IMemoryCache"/>.
9+
/// </summary>
710
public abstract class MemoryCacheBaseBuilder
811
{
12+
/// <summary>
13+
/// Abstract <see cref="MemoryCacheBaseBuilder"/> class.
14+
/// </summary>
15+
/// <param name="services"><see cref="IServiceProvider"/> providing the current <see cref="IMemoryCache"/>.</param>
916
public MemoryCacheBaseBuilder(IServiceProvider services)
1017
{
1118
this.MemoryCache = services.GetRequiredService<IMemoryCache>();

src/MyTested.AspNetCore.Mvc.Caching/Builders/Data/MemoryCacheWithBuilder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
using Microsoft.Extensions.Caching.Memory;
77
using Utilities.Extensions;
88

9-
/// <summary>
10-
/// Used for building mocked <see cref="IMemoryCache"/>.
11-
/// </summary>
9+
/// <inheritdoc />
1210
public class MemoryCacheWithBuilder : MemoryCacheBaseBuilder, IAndWithMemoryCacheBuilder
1311
{
1412
/// <summary>

src/MyTested.AspNetCore.Mvc.Caching/Builders/Data/MemoryCacheWithoutBuilder.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,40 @@
33
using System;
44
using System.Collections.Generic;
55
using Contracts.Data;
6+
using Microsoft.Extensions.Caching.Memory;
67
using Utilities.Extensions;
78

9+
/// <inheritdoc />
810
public class MemoryCacheWithoutBuilder : MemoryCacheBaseBuilder, IAndWithoutMemoryCacheBuilder
911
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="MemoryCacheWithoutBuilder"/> class.
14+
/// </summary>
15+
/// <param name="services"><see cref="IServiceProvider"/> providing the current <see cref="IMemoryCache"/>.</param>
1016
public MemoryCacheWithoutBuilder(IServiceProvider services) : base(services) { }
1117

18+
/// <inheritdoc />
1219
public IAndWithoutMemoryCacheBuilder WithoutEntry(object key)
1320
{
1421
this.MemoryCache.Remove(key);
1522
return this;
1623
}
1724

25+
/// <inheritdoc />
1826
public IAndWithoutMemoryCacheBuilder WithoutEntries(IEnumerable<object> keys)
1927
{
2028
this.MemoryCache.AsMemoryCacheMock().RemoveKeys(keys);
2129
return this;
2230
}
2331

32+
/// <inheritdoc />
2433
public IAndWithoutMemoryCacheBuilder ClearCache()
2534
{
2635
this.MemoryCache.AsMemoryCacheMock().ClearCache();
2736
return this;
2837
}
2938

39+
/// <inheritdoc />
3040
public IWithoutMemoryCacheBuilder AndAlso() => this;
3141
}
3242
}

src/MyTested.AspNetCore.Mvc.Caching/ComponentBuilderCachingExtensions.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,50 @@ public static TBuilder WithMemoryCache<TBuilder>(
3131
return actualBuilder.Builder;
3232
}
3333

34+
/// <summary>
35+
/// Clear all entities from <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/> service.
36+
/// </summary>
37+
/// <typeparam name="TBuilder">Class representing ASP.NET Core MVC test builder.</typeparam>
38+
/// <param name="builder">Instance of <see cref="IBaseTestBuilderWithComponentBuilder{TBuilder}"/> type.</param>
39+
/// <returns>The same component builder.</returns>
3440
public static TBuilder WithoutMemoryCache<TBuilder>(
3541
this IBaseTestBuilderWithComponentBuilder<TBuilder> builder)
3642
where TBuilder : IBaseTestBuilder
3743
=> builder.WithoutMemoryCache(cache => cache.ClearCache());
3844

45+
/// <summary>
46+
/// Remove given entity with key from <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/> service.
47+
/// </summary>
48+
/// <typeparam name="TBuilder">Class representing ASP.NET Core MVC test builder.</typeparam>
49+
/// <param name="builder">Instance of <see cref="IBaseTestBuilderWithComponentBuilder{TBuilder}"/> type.</param>
50+
/// <param name="key">Key of the entity that will be removed.</param>
51+
/// <returns>The same component builder.</returns>
3952
public static TBuilder WithoutMemoryCache<TBuilder>(
4053
this IBaseTestBuilderWithComponentBuilder<TBuilder> builder,
4154
object key)
4255
where TBuilder : IBaseTestBuilder
4356
=> builder.WithoutMemoryCache(cache => cache.WithoutEntry(key));
4457

58+
/// <summary>
59+
/// Remove given entities from <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/> service.
60+
/// </summary>
61+
/// <typeparam name="TBuilder">Class representing ASP.NET Core MVC test builder.</typeparam>
62+
/// <param name="builder">Instance of <see cref="IBaseTestBuilderWithComponentBuilder{TBuilder}"/> type.</param>
63+
/// <param name="keys">Keys of the entities that will be removed.</param>
64+
/// <returns>The same component builder.</returns>
4565
public static TBuilder WithoutMemoryCache<TBuilder>(
4666
this IBaseTestBuilderWithComponentBuilder<TBuilder> builder,
4767
IEnumerable<object> keys)
4868
where TBuilder : IBaseTestBuilder
4969
=> builder.WithoutMemoryCache(cache => cache.WithoutEntries(keys));
5070

71+
/// <summary>
72+
/// Remove entity or entities from <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/> service.
73+
/// </summary>
74+
/// <typeparam name="TBuilder">Class representing ASP.NET Core MVC test builder.</typeparam>
75+
/// <param name="builder">Instance of <see cref="IBaseTestBuilderWithComponentBuilder{TBuilder}"/> type.</param>
76+
/// <param name="memoryCacheBuilder">Action setting the <see cref="Microsoft.Extensions.Caching.Memory.IMemoryCache"/> values by using <see cref="IWithMemoryCacheBuilder"/>.</param>
77+
/// <returns>The same component builder.</returns>
5178
public static TBuilder WithoutMemoryCache<TBuilder>(
5279
this IBaseTestBuilderWithComponentBuilder<TBuilder> builder,
5380
Action<IWithoutMemoryCacheBuilder> memoryCacheBuilder)

0 commit comments

Comments
 (0)