コード例 #1
0
        public async Task LiveLogIsFollowed()
        {
            await app.SynchronizationContext.InvokeAndAwait(async() =>
            {
                var testLog = app.Model.TempFilesManager.GenerateNewName();

                using (var logWriter = new StreamWriter(testLog, append: false))
                {
                    Log(logWriter, "initial line");

                    await app.EmulateFileDragAndDrop(testLog);

                    await app.WaitForLogDisplayed("initial line");

                    for (int i = 0; i < 10; ++i)
                    {
                        Log(logWriter, $"test {i}");

                        var expectedLog = string.Join("\n",
                                                      new[] { "initial line" }.Union(
                                                          Enumerable.Range(0, i + 1).Select(j => $"test {j}")));
                        await app.WaitForLogDisplayed(expectedLog);
                    }
                }
            });
        }
コード例 #2
0
 public async Task CanLoadAndDetectFormatOfLocalLog()
 {
     await app.SynchronizationContext.InvokeAndAwait(async() =>
     {
         await app.EmulateFileDragAndDrop(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));
         await app.WaitFor(IsXmlWriterTraceListenerLogIsLoaded);
     });
 }
コード例 #3
0
        public async Task OpeningTheSameLogTwiceHasNoEffect(TestAppInstance app)
        {
            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));

            Check.That(app.ModelObjects.LogSourcesManager.Items.Count()).IsEqualTo(1);

            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            Check.That(app.ModelObjects.LogSourcesManager.Items.Count()).IsEqualTo(1);
        }
コード例 #4
0
        public async Task LiveLogCanBeDeletedAndRecreated(TestAppInstance app)
        {
            var testLog = app.ModelObjects.TempFilesManager.GenerateNewName();

            using (var logWriter = new StreamWriter(testLog, append: false))
            {
                Log(logWriter, "test1");
                Log(logWriter, "test2");
                Log(logWriter, "test3");

                await app.EmulateFileDragAndDrop(testLog);

                await app.WaitForLogDisplayed("test1\ntest2\ntest3");
            }

            File.Delete(testLog);

            await app.WaitForLogDisplayed("");

            using (var logWriter = new StreamWriter(testLog, append: false))
            {
                Log(logWriter, "test4");
                Log(logWriter, "test5");
                Log(logWriter, "test6");

                await app.WaitForLogDisplayed("test4\ntest5\ntest6");
            }
        }
コード例 #5
0
        public async Task LiveLogCanBeRewritten(TestAppInstance app)
        {
            var testLog = app.ModelObjects.TempFilesManager.GenerateNewName();

            using (var stream = new FileStream(testLog,
                                               FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                using (var logWriter = new StreamWriter(stream, Encoding.ASCII, 1024, leaveOpen: true))
                {
                    Log(logWriter, "test1");
                    Log(logWriter, "test2");

                    await app.EmulateFileDragAndDrop(testLog);

                    await app.WaitForLogDisplayed("test1\ntest2");
                }

                stream.SetLength(0);
                stream.Position = 0;

                using (var logWriter = new StreamWriter(stream, Encoding.ASCII, 1024, leaveOpen: true))
                {
                    Log(logWriter, "test4");

                    await app.WaitForLogDisplayed("test4");
                }
            }
        }
コード例 #6
0
        public async Task CanSaveAsLogFromZipContainer()
        {
            await app.SynchronizationContext.InvokeAndAwait(async() =>
            {
                CloseDialog();
                app.Presentation.AlertPopup.ShowPopup(null, null, UI.Presenters.AlertFlags.None).ReturnsForAnyArgs(UI.Presenters.AlertFlags.Yes);
                app.ViewModel.SourcesManager.OnDeleteAllLogSourcesButtonClicked();
                await app.EmulateFileDragAndDrop(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1AndImage.zip"));
                await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);
                app.ViewModel.SourcesList.OnSelectionChange(new[] {
                    (SrcListItem)app.ViewModel.SourcesList.RootItem.Children[0]
                });
                await OpenDialog();

                Assert.IsFalse(DialogState.SaveAsButton.Disabled);
                Assert.IsFalse(DialogState.SaveAsButton.Hidden);

                var destinationFileName = app.Model.TempFilesManager.GenerateNewName();
                app.Mocks.FileDialogs.SaveFileDialog(Arg.Any <UI.Presenters.SaveFileDialogParams>()).ReturnsForAnyArgs(destinationFileName);
                ViewModel.OnSaveAsButtonClicked();
                app.Mocks.FileDialogs.Received(1).SaveFileDialog(Arg.Any <UI.Presenters.SaveFileDialogParams>());

                var savedLog = File.ReadAllText(destinationFileName);

                var head = "<E2ETraceEvent xmlns=\"http://schemas.microsoft.com/2004/06/E2ETraceEvent\"><System xmlns=\"http://schemas.microsoft.com/2004/06/windows/eventlog/system\"><EventID>0</EventID><Type>3</Type><SubType Name=\"Start\">0</SubType><Level>255</Level><TimeCreated SystemTime=\"2011-07-24T10:37:25.9854589Z\" /><Source Name=\"SampleApp\" />";
                Assert.AreEqual(head, savedLog.Substring(0, head.Length));
            });
        }
コード例 #7
0
 public async Task CanOpenPasswordProtectedZipExtractAndFindKnownLogFormatInArchive(TestAppInstance app)
 {
     app.Mocks.CredentialsCache.QueryCredentials(
         Arg.Is <Uri>(v => v.ToString().Contains("XmlWriterTraceListener1AndImage.PasswordProtected.zip")), null)
     .ReturnsForAnyArgs(new System.Net.NetworkCredential("", "Pa$$w0rd"));
     await app.SynchronizationContext.InvokeAndAwait(async() =>
     {
         await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1AndImage.PasswordProtected.zip"));
         await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));
     });
 }
コード例 #8
0
        public async Task WhenLogIsOpenALogHistoryEntryIsAdded(TestAppInstance app)
        {
            Check.That(app.ModelObjects.RecentlyUsedLogs.GetMRUListSize()).IsEqualTo(0);

            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            Check.That(app.ModelObjects.RecentlyUsedLogs.GetMRUListSize()).IsEqualTo(1);

            await app.EmulateUrlDragAndDrop(app.Samples.GetSampleAsUri("XmlWriterTraceListener1.xml"));

            Check.That(app.ModelObjects.RecentlyUsedLogs.GetMRUListSize()).IsEqualTo(2);
        }
コード例 #9
0
        public async Task WhenLogIsOpenALogHistoryEntryIsAdded()
        {
            await app.SynchronizationContext.InvokeAndAwait(async() =>
            {
                Assert.AreEqual(0, app.Model.RecentlyUsedLogs.GetMRUListSize());

                await app.EmulateFileDragAndDrop(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

                Assert.AreEqual(1, app.Model.RecentlyUsedLogs.GetMRUListSize());

                await app.EmulateUrlDragAndDrop(samples.GetSampleAsUri("XmlWriterTraceListener1.xml").ToString());
                Assert.AreEqual(2, app.Model.RecentlyUsedLogs.GetMRUListSize());
            });
        }
コード例 #10
0
        public async Task BeforeEach(TestAppInstance app)
        {
            this.appInstance = app;

            var preprocTask = app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListenerAndTextWriterTraceListener.zip"));

            await app.WaitFor(() => app.ViewModel.PreprocessingUserInteractions.DialogData != null);

            app.ViewModel.PreprocessingUserInteractions.OnCloseDialog(accept: true);

            await preprocTask;

            await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);
        }
コード例 #11
0
        public async Task BeforeEach()
        {
            app = await TestAppInstance.Create();

            await app.SynchronizationContext.InvokeAndAwait(async() =>
            {
                tempLogFileName = Path.Combine(app.AppDataDirectory, "XmlWriterTraceListener1.xml");
                File.Copy(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"), tempLogFileName, overwrite: true);
                await app.EmulateFileDragAndDrop(tempLogFileName);
                await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);
                app.ViewModel.SourcesList.OnSelectionChange(new[] {
                    (SrcListItem)app.ViewModel.SourcesList.RootItem.Children[0]
                });
                await OpenDialog();
            });
        }
コード例 #12
0
        public async Task BeforeEach()
        {
            app = await TestAppInstance.Create();

            await app.SynchronizationContext.InvokeAndAwait(async() =>
            {
                var preprocTask = app.EmulateFileDragAndDrop(await samples.GetSampleAsLocalFile("XmlWriterTraceListenerAndTextWriterTraceListener.zip"));

                await app.WaitFor(() => app.ViewModel.PreprocessingUserInteractions.DialogData != null);
                app.ViewModel.PreprocessingUserInteractions.OnCloseDialog(accept: true);

                await preprocTask;

                await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);
            });
        }
コード例 #13
0
ファイル: ViewModeTests.cs プロジェクト: sabrogden/logjoint
        public async Task BeforeEach(TestAppInstance app)
        {
            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            await app.WaitFor(() => !app.ViewModel.LoadedMessagesLogViewer.ViewLines.IsEmpty);

            // todo: emulate UI clicks for search
            var filters = app.ModelObjects.FiltersFactory.CreateFiltersList(FilterAction.Exclude, FiltersListPurpose.Search);

            filters.Insert(0, app.ModelObjects.FiltersFactory.CreateFilter(FilterAction.Include, "", true, new Search.Options {
                Template = "file"
            }));
            app.ModelObjects.SearchManager.SubmitSearch(new SearchAllOptions {
                Filters = filters
            });
            await app.WaitFor(() => !app.ViewModel.SearchResultLogViewer.ViewLines.IsEmpty && app.ModelObjects.SearchManager.Results[0].Status == SearchResultStatus.Finished);
        }
コード例 #14
0
        public async Task UnzippingCanBeCancelled(TestAppInstance app)
        {
            var preprocessorTask = app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("network_trace_with_keys_1.as_pdml.zip"));
            await app.WaitFor(() => (app.ViewModel.SourcesList.RootItem.Children.ElementAtOrDefault(0)?.ToString() ?? "").Contains("Unpacking"));

            app.ViewModel.SourcesList.OnSelectAllShortcutPressed();
            app.Mocks.AlertPopup.ShowPopup(null, null, UI.Presenters.AlertFlags.None).ReturnsForAnyArgs(
                UI.Presenters.AlertFlags.Yes);
            var stopwatch = Stopwatch.StartNew();

            app.ViewModel.SourcesList.OnDeleteButtonPressed();
            await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 0);

            stopwatch.Stop();
            Check.That(stopwatch.ElapsedMilliseconds).IsStrictlyLessThan(1000);
            Check.That(preprocessorTask.IsCanceled).IsTrue();
        }
コード例 #15
0
        public async Task BeforeEach(TestAppInstance app)
        {
            appInstance = app;
            samples     = app.Samples;

            tempLogFileName = Path.Combine(app.AppDataDirectory, "XmlWriterTraceListener1.xml");
            File.Copy(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"), tempLogFileName, overwrite: true);
            await app.EmulateFileDragAndDrop(tempLogFileName);

            await app.WaitFor(() => app.ViewModel.LoadedMessagesLogViewer.ViewLines.Length > 0);

            await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);

            app.ViewModel.SourcesList.OnSelectionChange(new[] {
                (SrcListItem)app.ViewModel.SourcesList.RootItem.Children[0]
            });
            await OpenDialog();
        }
コード例 #16
0
        public async Task DisplaysProgressDuringUnzipping(TestAppInstance app)
        {
            var preprocessorTask = app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("network_trace_with_keys_1.as_pdml.zip"));
            int lastPercent      = 0;

            for (int iter = 0; iter < 3; ++iter)
            {
                await app.WaitFor(() =>
                {
                    var displayText = app.ViewModel.SourcesList.RootItem.Children.ElementAtOrDefault(0)?.ToString() ?? "";
                    var m           = Regex.Match(displayText, @"Unpacking (\d+)\%");
                    if (m.Success)
                    {
                        var percent = int.Parse(m.Groups[1].Value);
                        if (percent > lastPercent && percent < 100)
                        {
                            lastPercent = percent;
                            return(true);
                        }
                    }
                    return(false);
                });
            }
        }
コード例 #17
0
ファイル: Extensions.cs プロジェクト: sabrogden/logjoint
 Task IUtils.EmulateFileDragAndDrop(string filePath) => app.EmulateFileDragAndDrop(filePath);
コード例 #18
0
        public async Task CanExtractGZippedLog(TestAppInstance app)
        {
            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml.gz"));

            await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));
        }
コード例 #19
0
        public async Task CanLoadAndDetectFormatOfLocalLog(TestAppInstance app)
        {
            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));
        }