/// <inheritdoc />
        public override Stream GetStream(HttpContent parent, HttpContentHeaders headers)
        {
            if (MultipartFormDataStreamProviderHelper.IsFileContent(parent, headers))
            {
                RemoteStreamInfo remoteStreamInfo = GetRemoteStream(parent, headers);
                if (remoteStreamInfo == null)
                {
                    throw Error.InvalidOperation(
                              Properties.Resources.RemoteStreamInfoCannotBeNull,
                              "GetRemoteStream",
                              GetType().Name
                              );
                }
                FileData.Add(
                    new MultipartRemoteFileData(
                        headers,
                        remoteStreamInfo.Location,
                        remoteStreamInfo.FileName
                        )
                    );

                return(remoteStreamInfo.RemoteStream);
            }

            return(new MemoryStream());
        }
        public void Constructor_InitializesCorrectly()
        {
            // Arrange
            HttpContentHeaders headers = FormattingUtilities.CreateEmptyContentHeaders();
            string remoteFileURL = "http://some/path/to";
            string fileName = "Name";
            Stream stream = new MemoryStream();

            // Act
            RemoteStreamInfo fileData = new RemoteStreamInfo(stream, remoteFileURL, fileName);

            // Assert
            Assert.Same(stream, fileData.RemoteStream);
            Assert.Same(remoteFileURL, fileData.Location);
            Assert.Same(fileName, fileData.FileName);
        }
Esempio n. 3
0
        public void Constructor_InitializesCorrectly()
        {
            // Arrange
            HttpContentHeaders headers       = FormattingUtilities.CreateEmptyContentHeaders();
            string             remoteFileURL = "http://some/path/to";
            string             fileName      = "Name";
            Stream             stream        = new MemoryStream();

            // Act
            RemoteStreamInfo fileData = new RemoteStreamInfo(stream, remoteFileURL, fileName);

            // Assert
            Assert.Same(stream, fileData.RemoteStream);
            Assert.Same(remoteFileURL, fileData.Location);
            Assert.Same(fileName, fileData.FileName);
        }