File tree Expand file tree Collapse file tree
src/MyTested.AspNetCore.Mvc.Caching/Builders
Contracts/Data/DistributedCache/WithoutDistributedCache Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Data
22{
3+ /// <summary>
4+ /// Used for adding AndAlso() method to the <see cref="Microsoft.Extensions.Caching.Distributed.IDistributedCache"/> builder.
5+ /// </summary>
36 public interface IAndWithoutDistributedCache : IWithoutDistributedCache
47 {
8+ /// <summary>
9+ /// AndAlso method for better readability when building <see cref="Microsoft.Extensions.Caching.Distributed.IDistributedCache"/>.
10+ /// </summary>
11+ /// <returns></returns>
512 IWithoutDistributedCache AndAlso();
613 }
714}
Original file line number Diff line number Diff line change 11namespace MyTested.AspNetCore.Mvc.Builders.Contracts.Data
22{
33 using System.Collections.Generic;
4+ using Microsoft.Extensions.Caching.Distributed;
45
6+ /// <summary>
7+ /// Used for building mocked <see cref="IDistributedCache"/>.
8+ /// </summary>
59 public interface IWithoutDistributedCache
610 {
11+ /// <summary>
12+ /// Remove cache entry to the mocked <see cref="IDistributedCache"/>.
13+ /// </summary>
14+ /// <param name="key">Key of the cache entry.</param>
15+ /// <returns>The same <see cref="IAndWithoutDistributedCache"/>.</returns>
716 IAndWithoutDistributedCache WithoutEntry(object key);
817
18+ /// <summary>
19+ /// Remove cache entries to the mocked <see cref="IDistributedCache"/>.
20+ /// </summary>
21+ /// <param name="keys">Keys of the cache entries.</param>
22+ /// <returns>The same <see cref="IAndWithoutDistributedCache"/>.</returns>
923 IAndWithoutDistributedCache WithoutEntries(IEnumerable<object> keys);
1024
25+ /// <summary>
26+ /// Remove cache params to the mocked <see cref="IDistributedCache"/>.
27+ /// </summary>
28+ /// <param name="keys">Keys of the cache entries.</param>
29+ /// <returns>The same <see cref="IAndWithoutDistributedCache"/>.</returns>
1130 IAndWithoutDistributedCache WithoutEntries(params object[] keys);
1231
32+ /// <summary>
33+ /// Clear all entries persisted into the <see cref="IDistributedCache"/>.
34+ /// </summary>
35+ /// <returns>The same <see cref="IAndWithoutDistributedCache"/>.</returns>
1336 IAndWithoutDistributedCache WithoutAllEntries();
1437 }
1538}
Original file line number Diff line number Diff line change 44 using Microsoft.Extensions.Caching.Distributed;
55 using Microsoft.Extensions.DependencyInjection;
66
7+ /// <summary>
8+ /// Used for building mocked <see cref="IDistributedCache"/>.
9+ /// </summary>
710 public abstract class BaseDistributedCacheBuilder
811 {
12+ /// <summary>
13+ /// Abstract <see cref="BaseDistributedCacheBuilder"/> class.
14+ /// </summary>
15+ /// <param name="services"><see cref="IServiceProvider"/> providing the current <see cref="IDistributedCache"/>.</param>
916 public BaseDistributedCacheBuilder(IServiceProvider services)
1017 => this.DistributedCache = services.GetRequiredService<IDistributedCache>();
1118
Original file line number Diff line number Diff line change 11namespace MyTested.AspNetCore.Mvc.Builders.Data.DistributedCache.WithoutDistributedCache
22{
33 using System;
4+ using System.Collections.Generic;
45 using Microsoft.Extensions.Caching.Distributed;
6+ using MyTested.AspNetCore.Mvc.Builders.Contracts.Data;
57
6- public class WithoutDistributedCacheBuilder : BaseDistributedCacheBuilder
8+ public class WithoutDistributedCacheBuilder : BaseDistributedCacheBuilder, IAndWithoutDistributedCache
79 {
810 /// <summary>
911 /// Initializes a new instance of the <see cref="WithoutDistributedCacheBuilder"/> class.
@@ -13,5 +15,32 @@ public WithoutDistributedCacheBuilder(IServiceProvider services)
1315 : base(services)
1416 {
1517 }
18+
19+ /// <inheritdoc />
20+ public IAndWithoutDistributedCache WithoutAllEntries()
21+ {
22+ throw new NotImplementedException();
23+ }
24+
25+ /// <inheritdoc />
26+ public IAndWithoutDistributedCache WithoutEntries(IEnumerable<object> keys)
27+ {
28+ throw new NotImplementedException();
29+ }
30+
31+ /// <inheritdoc />
32+ public IAndWithoutDistributedCache WithoutEntries(params object[] keys)
33+ {
34+ throw new NotImplementedException();
35+ }
36+
37+ /// <inheritdoc />
38+ public IAndWithoutDistributedCache WithoutEntry(object key)
39+ {
40+ throw new NotImplementedException();
41+ }
42+
43+ /// <inheritdoc />
44+ public IWithoutDistributedCache AndAlso() => this;
1645 }
1746}
Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ public abstract class BaseMemoryCacheBuilder
1616 public BaseMemoryCacheBuilder(IServiceProvider services)
1717 => this.MemoryCache = services.GetRequiredService<IMemoryCache>();
1818
19+ /// <summary>
20+ /// Gets the mocked <see cref="IMemoryCache"/>.
21+ /// </summary>
22+ /// <value>Built <see cref="IMemoryCache"/>.</value>
1923 protected IMemoryCache MemoryCache { get; private set; }
2024 }
2125}
You can’t perform that action at this time.
0 commit comments