private static CacheKey GetCacheKeyForFulfillmentLocationsByScope(GetFulfillmentLocationsByScopeParam param)
        {
            var cacheKey = new CacheKey(CacheConfigurationCategoryNames.FulfillmentLocationsByScope, param.Scope);

            cacheKey.AppendKeyParts(param.IncludeChildScopes, param.IncludeSchedules);

            return(cacheKey);
        }
Beispiel #2
0
        protected virtual GetFulfillmentLocationsByScopeParam GetFulfillmentLocationsByScopeParam(GetFulfillmentLocationParam param)
        {
            var p = new GetFulfillmentLocationsByScopeParam
            {
                Scope = param.Scope,
                IncludeChildScopes = false,
                IncludeSchedules   = false
            };

            return(p);
        }
Beispiel #3
0
        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);
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        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>()));
        }
Beispiel #7
0
        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");
        }
Beispiel #8
0
        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)));
        }
Beispiel #9
0
        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);
        }
Beispiel #11
0
        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);
        }