public RedisGuidDataDecoratorTests() { _cacheMock = Substitute.For <IDistributedCache>(); _dbMock = Substitute.For <IGuidDataRepository>(); _repo = new RedisGuidDataDecorator(_dbMock, _cacheMock); }
public GuidDataServiceTests() { var _testHostBuilder = GuidDataCRUD.Web.Program.CreateWebHostBuilder(new string[] { }); _loggerProvMock = Substitute.For <ILogger <GuidDataService> >(); _loggerRepoMock = Substitute.For <ILogger <SqlGuidDataRepository> >(); _repoMock = Substitute.For <IGuidDataRepository>(); _appSettings = Options.Create(new AppSettings() { DefaultExpireDays = 30 }); _provider = new GuidDataService(_repoMock, _appSettings); }
public GuidDataControllerTest() { var _testHostBuilder = GuidDataCRUD.Web.Program.CreateWebHostBuilder(new string[] { }); _loggerProvMock = Substitute.For <ILogger <GuidDataService> >(); _loggerRepoMock = Substitute.For <ILogger <SqlGuidDataRepository> >(); _repoMock = Substitute.For <IGuidDataRepository>(); _testHostBuilder.ConfigureTestServices(collection => { collection.AddScoped(c => _loggerProvMock); collection.AddScoped(c => _loggerRepoMock); collection.AddScoped(c => _repoMock); collection.Configure <AppSettings>((settings) => { settings.DefaultExpireDays = 30; }); }); _server = new TestServer(_testHostBuilder); _client = _server.CreateClient(); }
/// <summary> /// Constructor /// </summary> /// <param name="repo">The GuidData repository</param> /// <param name="settings" cref="AppSettings">The settings from app config</param> public GuidDataService(IGuidDataRepository repo, IOptions <AppSettings> settings) { _repo = repo; _defaultExpireDays = settings?.Value.DefaultExpireDays ?? 30; }
/// <summary> /// Constructor /// </summary> /// <param name="decorated">The repository delegate further processing data</param> /// <param name="cache">The distributed cache</param> public RedisGuidDataDecorator(IGuidDataRepository decorated, IDistributedCache cache) { _decorated = decorated; _cache = cache; }