Esempio n. 1
0
        private void ProcessAcceptedConnection(ISocket acceptedConnection)
        {
            using (var sourceStream = acceptedConnection.GetStream())
            {
                var dialogServer = new ProtocolDialogServer(sourceStream);
                var dialogData   = dialogServer.AcceptDialog();

                Log.Information($"Received event {dialogData.FileAction} for file {dialogData.RelativeFilePath}.");

                var constructor = _fileStrategies[dialogData.FileAction];
                IFileReceiverStrategy currentStrategy = constructor(dialogServer);
                currentStrategy.ProcessRequest();
            }
        }
        public void AcceptDialog_ShouldReturnProtocolData()
        {
            // Arrange
            var buffer = GetInitBuffer();
            var stream = new MemoryStream(buffer);

            // Act
            var dialog = new ProtocolDialogServer(stream);
            var data   = dialog.AcceptDialog();

            // Assert
            Assert.Equal(1, data.Version);
            Assert.Equal(FileAction.Change, data.FileAction);
            Assert.Equal(FileType.Unknown, data.FileType);
            Assert.Equal("file.my", data.RelativeFilePath);
        }