示例#1
0
        public void ShouldUseUploadUrlFromSettingsForUpload()
        {
            _mockPublisherUtils
            .Setup(
                p =>
                p.WriteEventsToZipStream(
                    It.IsAny <IEnumerable <IDEEvent> >(),
                    It.IsAny <Stream>(),
                    It.IsAny <Action>()))
            .Returns((IEnumerable <IDEEvent> events, Stream stream, Action action) => events.Any());

            HttpPublisher httpPublisher = null;

            _mockExporter
            .Setup(exporter => exporter.Export(It.IsAny <DateTimeOffset>(), It.IsAny <HttpPublisher>()))
            .Callback <DateTimeOffset, IPublisher>(
                (exportTime, publisher) => httpPublisher = (HttpPublisher)publisher);

            WhenExportIsExecuted(UploadWizardControl.ExportType.HttpUpload);
            try
            {
                // There's currently no clean way to find out what Url is passed to the publisher. Therefore, we
                // invoke the publisher and rely on that it calls IPublisherUtils.UploadEventsByHttp and then fails
                // because the utils return null.
                httpPublisher.Publish(null, new List <IDEEvent> {
                    new WindowEvent()
                }, () => { });
            }
            catch (NullReferenceException) { }

            _mockPublisherUtils.Verify(
                utils =>
                utils.UploadEventsByHttp(It.IsAny <IIoUtils>(), new Uri(TestUploadUrl), It.IsAny <MemoryStream>()));
        }
示例#2
0
        private IPublisher CreatePublisher()
        {
            IPublisher publisher;

            if (_exportType == UploadWizardControl.ExportType.ZipFile)
            {
                publisher = new FilePublisher(AskForExportLocation);
            }
            else
            {
                publisher = new HttpPublisher(GetUploadUrl());
            }
            return(publisher);
        }
示例#3
0
 public void SetUp()
 {
     _uut = new HttpPublisher(ValidUri, TestEventCountPerUpload);
 }