Dreamine.FullKit.Wpf.Tests 1.0.0.0
Dreamine.FullKit.Wpf.Tests 기능을 검증하는 자동화 테스트 프로젝트입니다.
로딩중...
검색중...
일치하는것 없음
LoggingWpfTests.cs
이 파일의 문서화 페이지로 가기
1using Dreamine.Logging.Interfaces;
2using Dreamine.Logging.Models;
3using Dreamine.Logging.Services;
4using Dreamine.Logging.Wpf.Services;
5using Dreamine.Logging.Wpf.ViewModels;
6using System.Windows.Threading;
7
9
18public sealed class LoggingWpfTests
19{
28 [Fact]
30 {
31 var store = new InMemoryLogStore();
32 var first = Entry("first");
33 var second = Entry("second");
34 store.Add(first);
35 store.Add(second);
36
37 using var viewModel = new DreamineLogPanelViewModel(
38 store,
39 new WpfLogUiDispatcher(),
40 displayCapacity: 1);
41
42 viewModel.SelectedEntry = second;
43
44 Assert.Single(viewModel.Entries);
45 Assert.Same(second, viewModel.Entries[0]);
46 Assert.Contains("second", viewModel.SelectedDetailText);
47 }
48
57 [Fact]
59 {
60 var store = new InMemoryLogStore();
61 store.Add(Entry("message"));
62
63 using var viewModel = new DreamineLogPanelViewModel(store, new WpfLogUiDispatcher());
64
65 viewModel.Clear();
66
67 Assert.Empty(store.GetEntries());
68 }
69
78 [Fact]
80 {
81 var store = new InMemoryLogStore();
82
83 using var viewModel = new DreamineLogPanelViewModel(
84 store,
86
87 Assert.Empty(viewModel.Entries);
88 }
89
114 private static DreamineLogEntry Entry(string message)
115 {
116 return new DreamineLogEntry(
117 DateTimeOffset.UnixEpoch,
118 DreamineLogLevel.Info,
119 "Test",
120 message,
121 exception: null,
122 threadId: 1);
123 }
124
133 private sealed class TestLogUiDispatcher : ILogUiDispatcher
134 {
143 public Dispatcher Dispatcher { get; } = Dispatcher.CurrentDispatcher;
144
161 public void Invoke(Action action)
162 {
163 action();
164 }
165
182 public void BeginInvoke(Action action)
183 {
184 action();
185 }
186 }
187}
static DreamineLogEntry Entry(string message)