|
1 | 1 | using Dapper; |
| 2 | +using Lanceur.Core.Configuration; |
| 3 | +using Lanceur.Core.Configuration.Sections.Infrastructure; |
2 | 4 | using Lanceur.Core.Models; |
3 | 5 | using Lanceur.Core.Repositories; |
4 | 6 | using Lanceur.Core.Services; |
5 | 7 | using Lanceur.Infra.Services; |
6 | 8 | using Lanceur.Infra.SQLite.DataAccess; |
7 | 9 | using Lanceur.Infra.SQLite.DbActions; |
8 | 10 | using Lanceur.Infra.SQLite.Repositories; |
| 11 | +using Lanceur.Infra.Win32.Services; |
9 | 12 | using Lanceur.Infra.Win32.Thumbnails; |
10 | 13 | using Lanceur.Infra.Win32.Thumbnails.Strategies; |
11 | 14 | using Lanceur.Tests.Tools; |
@@ -157,6 +160,40 @@ public void When_searching_alias_Then_additional_are_not_loaded() |
157 | 160 | ); |
158 | 161 | } |
159 | 162 |
|
| 163 | + [Fact] |
| 164 | + public async Task When_strategy_resolves_thumbnail_Then_remaining_strategies_are_skipped() |
| 165 | + { |
| 166 | + // ARRANGE |
| 167 | + var alias = new AliasQueryResult { FileName = "some_file_that_does_not_exist.exe" }; |
| 168 | + var processed = new TaskCompletionSource(); |
| 169 | + |
| 170 | + var first = Substitute.For<IThumbnailStrategy>(); |
| 171 | + var second = Substitute.For<IThumbnailStrategy>(); |
| 172 | + var third = Substitute.For<IThumbnailStrategy>(); |
| 173 | + |
| 174 | + first.Priority.Returns(0); |
| 175 | + first.UpdateThumbnailAsync(Arg.Any<AliasQueryResult>(), Arg.Any<CancellationToken>()) |
| 176 | + .Returns(_ => { |
| 177 | + processed.TrySetResult(); |
| 178 | + return Task.FromResult(true); |
| 179 | + }); |
| 180 | + second.Priority.Returns(1); |
| 181 | + third.Priority.Returns(2); |
| 182 | + |
| 183 | + var section = Substitute.For<ISection<ThumbnailPipelineSection>>(); |
| 184 | + section.Value.Returns(new ThumbnailPipelineSection { ConsumerCount = 1 }); |
| 185 | + |
| 186 | + await using var service = new ThumbnailService(LoggerFactory, [first, second, third], section); |
| 187 | + |
| 188 | + // ACT |
| 189 | + service.UpdateThumbnail(alias); |
| 190 | + await processed.Task; |
| 191 | + |
| 192 | + // ASSERT |
| 193 | + await second.DidNotReceive().UpdateThumbnailAsync(Arg.Any<AliasQueryResult>(), Arg.Any<CancellationToken>()); |
| 194 | + await third.DidNotReceive().UpdateThumbnailAsync(Arg.Any<AliasQueryResult>(), Arg.Any<CancellationToken>()); |
| 195 | + } |
| 196 | + |
160 | 197 | [Theory] |
161 | 198 | [MemberData(nameof(GetStrategies))] |
162 | 199 | public async Task When_strategy_updates_thumbnail_Then_additional_parameters_are_not_removed( |
|
0 commit comments