Esempio n. 1
0
        public string BuildStringToAppend(HeaderName header)
        {
            if (header == HeaderName.Empty)
            {
                throw new ValidationException("An empty header name was specified.");
            }

            switch (header)
            {
            case string str when str == HeaderName.PredefinedHeaderNames.RequestTarget:
                return(_requestTargetHeaderAppender.BuildStringToAppend(header));

            case string str when str == HeaderName.PredefinedHeaderNames.Created:
                return(_createdHeaderAppender.BuildStringToAppend(header));

            case string str when str == HeaderName.PredefinedHeaderNames.Expires:
                return(_expiresHeaderAppender.BuildStringToAppend(header));

            case string str when str == HeaderName.PredefinedHeaderNames.Date:
                return(_dateHeaderAppender.BuildStringToAppend(header));

            default:
                return(_defaultHeaderAppender.BuildStringToAppend(header));
            }
        }
            public void ExcludesEmptyHeaderNames()
            {
                var headerNames = new[] {
                    HeaderName.PredefinedHeaderNames.RequestTarget,
                    HeaderName.Empty,
                    HeaderName.PredefinedHeaderNames.Date,
                    HeaderName.Empty,
                    new HeaderName("dalion_app_id")
                };

                A.CallTo(() => _headerAppender.BuildStringToAppend(A <HeaderName> ._))
                .ReturnsLazily(call => call.GetArgument <HeaderName>(0) + ",");

                A.CallTo(() => _nonceAppender.BuildStringToAppend(_nonce))
                .Returns("abc123,");

                var actual = _sut.Compose(_httpRequest, headerNames, _timeOfComposing, _expires, _nonce);

                var expected = "(request-target),date,dalion_app_id,abc123,";

                actual.Should().Be(expected);
            }