private static CacheKey GetCacheKeyForFulfillmentLocationsByScope(GetFulfillmentLocationsByScopeParam param) { var cacheKey = new CacheKey(CacheConfigurationCategoryNames.FulfillmentLocationsByScope, param.Scope); cacheKey.AppendKeyParts(param.IncludeChildScopes, param.IncludeSchedules); return(cacheKey); }
protected virtual GetFulfillmentLocationsByScopeParam GetFulfillmentLocationsByScopeParam(GetFulfillmentLocationParam param) { var p = new GetFulfillmentLocationsByScopeParam { Scope = param.Scope, IncludeChildScopes = false, IncludeSchedules = false }; return(p); }
public void WHEN_param_is_null_SHOULD_throw_ArgumentNullException() { //Arrange GetFulfillmentLocationsByScopeParam p = null; //Act var exception = Assert.ThrowsAsync <ArgumentNullException>(() => _sut.GetFulfillmentLocationsByScopeAsync(p)); //Assert exception.Should().NotBeNull(); exception.ParamName.ShouldBeEquivalentTo("param"); }
private static GetFulfillmentLocationsByScopeRequest GetFulfillmentLocationsByScopeRequest( GetFulfillmentLocationsByScopeParam param) { var request = new GetFulfillmentLocationsByScopeRequest { IncludeChildScopes = param.IncludeChildScopes, IncludeSchedules = param.IncludeSchedules, ScopeId = param.Scope }; return(request); }
public async Task WHEN_param_ok_SHOULD_return_Overture_result() { //Arrange var p = new GetFulfillmentLocationsByScopeParam { IncludeChildScopes = GetRandom.Boolean(), IncludeSchedules = GetRandom.Boolean(), Scope = GetRandom.String(6) }; //Act var results = await _sut.GetFulfillmentLocationsByScopeAsync(p); //Assert results.Should().NotBeNull(); }
public async Task WHEN_param_ok_SHOULD_call_OvertureClient() { //Arrange var p = new GetFulfillmentLocationsByScopeParam { IncludeChildScopes = GetRandom.Boolean(), IncludeSchedules = GetRandom.Boolean(), Scope = GetRandom.String(6) }; //Act var results = await _sut.GetFulfillmentLocationsByScopeAsync(p); //Assert _container.Verify <IOvertureClient>( ovClient => ovClient.SendAsync(It.IsNotNull <GetFulfillmentLocationsByScopeRequest>())); }
public void WHEN_scope_is_invalid_SHOULD_Throw_ArgumentException(string scope) { //Arrange var p = new GetFulfillmentLocationsByScopeParam { IncludeChildScopes = GetRandom.Boolean(), IncludeSchedules = GetRandom.Boolean(), Scope = scope }; //Act var exception = Assert.ThrowsAsync <ArgumentException>(() => _sut.GetFulfillmentLocationsByScopeAsync(p)); //Assert exception.Should().NotBeNull(); exception.ParamName.ShouldBeEquivalentTo("param"); exception.Message.Should().ContainEquivalentOf("scope"); }
public void WHEN_scope_is_invalid_SHOULD_Throw_ArgumentException(string scope) { //Arrange var p = new GetFulfillmentLocationsByScopeParam { IncludeChildScopes = GetRandom.Boolean(), IncludeSchedules = GetRandom.Boolean(), Scope = scope }; //Act Expression <Func <Task <List <FulfillmentLocation> > > > expression = () => _sut.GetFulfillmentLocationsByScopeAsync(p); var exception = Assert.ThrowsAsync <ArgumentException>(() => expression.Compile().Invoke()); //Assert exception.ParamName.Should().BeEquivalentTo(GetParamsInfo(expression)[0].Name); exception.Message.Should().StartWith(GetMessageOfNullWhiteSpace(nameof(p.Scope))); }
public async Task WHEN_param_ok_SHOULD_cache_result() { //Arrange var p = new GetFulfillmentLocationsByScopeParam { IncludeChildScopes = GetRandom.Boolean(), IncludeSchedules = GetRandom.Boolean(), Scope = GetRandom.String(6) }; //Act var results = await _sut.GetFulfillmentLocationsByScopeAsync(p); //3.8 upgrade //Assert _container.Verify <ICacheProvider>(provider => provider.GetOrAddAsync( It.IsNotNull <CacheKey>(), It.IsNotNull <Func <Task <List <FulfillmentLocation> > > >(), It.IsAny <Func <List <FulfillmentLocation>, Task> >(), It.IsAny <CacheKey>())); }
public Task <List <FulfillmentLocation> > GetFulfillmentLocationsByScopeAsync(GetFulfillmentLocationsByScopeParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (String.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Scope"), "param"); } var cacheKey = GetCacheKeyForFulfillmentLocationsByScope(param); var results = CacheProvider.GetOrAddAsync(cacheKey, () => { var request = GetFulfillmentLocationsByScopeRequest(param); var r = OvertureClient.SendAsync(request); return(r); }); return(results); }
public Task <List <FulfillmentLocation> > GetFulfillmentLocationsByScopeAsync(GetFulfillmentLocationsByScopeParam param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param)); } var cacheKey = GetCacheKeyForFulfillmentLocationsByScope(param); var results = CacheProvider.GetOrAddAsync(cacheKey, () => { var request = GetFulfillmentLocationsByScopeRequest(param); var r = OvertureClient.SendAsync(request); return(r); }); return(results); }