/// <exception cref="InvalidDataException"></exception>
        private HttpResponse <string> ParseNextSubresponseFrom(PeekableStreamReader reader, string boundary)
        {
            var currentLine = reader.ReadFirstNonEmptyLine();

            if (currentLine != BatchSerializeHelper.GetOpenBoundaryString(boundary))
            {
                throw new InvalidDataException("Response boundary missed");
            }

            currentLine = reader.ReadFirstNonEmptyLineOrThrow("Content type header not found");
            //  if (currentLine?.Trim() != HttpHelper.HttpRequestContentTypeHeaderString)
            if (!currentLine.Trim().StartsWith(HttpHelper.ContentTypeHeader))
            {
                throw new InvalidDataException("Content type has invalid format");
            }

            currentLine = reader.ReadFirstNonEmptyLineOrThrow("Status code is missed");

            var resultCode = BatchSerializeHelper.GetResultCodeOrThrow(currentLine);



            var content = BatchSerializeHelper.ReadUntilBoundaryOrThrow(reader, boundary);

            return(new HttpResponse <string>(
                       new ResponseInfo((HttpStatusCode)resultCode),
                       content));
        }
 public void GetResultCodeOrThrow_StringIsInvalid_Throws(string str)
 {
     Assert.Throws <InvalidDataException>(() => BatchSerializeHelper.GetResultCodeOrThrow(str));
 }
        public void GetResultCodeOrThrow_StringIsCorrect_SpecifiedCodeFound(string str, int code)
        {
            var actualCode = BatchSerializeHelper.GetResultCodeOrThrow(str);

            Assert.AreEqual(code, actualCode);
        }