Example #1
0
        public void CreatesFileNamesFromEventIndexAndType()
        {
            var events = new List <IDEEvent>
            {
                TestEventFactory.Some <UserProfileEvent>(),
                TestEventFactory.Some <EditEvent>(),
                TestEventFactory.Some <ErrorEvent>(),
                TestEventFactory.Some <WindowEvent>()
            };

            var stream = new MemoryStream();

            _uut.WriteEventsToZipStream(events, stream, () => { });

            var actual = GetFileEntriesFromZipStream(stream);

            Assert.AreEqual(new[] { "UserProfileEvent.json", "0-EditEvent.json", "1-ErrorEvent.json", "2-WindowEvent.json" }, actual);
        }
Example #2
0
        public void Publish(UserProfileEvent upe,
                            IEnumerable <IDEEvent> events,
                            Action progress)
        {
            var filename = _requestFileLocation();

            Asserts.Not(filename.IsNullOrEmpty(), Messages.NoFileGiven);

            try
            {
                using (var file = _ioUtils.OpenFile(filename, FileMode.Create, FileAccess.Write))
                {
                    _publisherUtils.WriteEventsToZipStream(events.Prepend(upe), file, progress);
                }
            }
            catch (Exception e)
            {
                Asserts.Fail(Messages.PublishingFileFailed, e.Message);
            }
        }
Example #3
0
        public void Publish(UserProfileEvent upe,
                            IEnumerable <IDEEvent> events,
                            Action progress)
        {
            var en = events.GetEnumerator();

            bool eventsWereWritten;

            do
            {
                var eventsToExport = Next(_eventCountPerUpload, en).PrependWith(upe);

                using (var stream = new MemoryStream())
                {
                    eventsWereWritten = _publisherUtils.WriteEventsToZipStream(eventsToExport, stream, progress);
                    if (eventsWereWritten)
                    {
                        _publisherUtils.UploadEventsByHttp(_ioUtils, _hostAddress, stream);
                    }
                }
            } while (eventsWereWritten);
        }