Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichb committed Oct 29, 2024
1 parent ba6de1a commit 8143cd9
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using JetBrains.Application;
using JetBrains.Application.Parts;
using JetBrains.DataFlow;
using Roflcopter.Plugin.TodoItems;

namespace Roflcopter.Plugin.Tests.TodoItems
{
[ShellComponent]
[ShellComponent(Instantiation.DemandAnyThreadSafe)]
internal class TestTodoItemsCountConsumer : ITodoItemsCountConsumer
{
[CanBeNull]
Expand Down
22 changes: 13 additions & 9 deletions Src/Roflcopter.Plugin.Tests/TodoItems/TodoItemsCountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void TodoItemsCountsWithCondition()
Test((consumer, settings) =>
{
var definitionText = "Todo\n Todo [Important] ";
RunGuarded(() => settings.SetValue((TodoItemsCountSettings s) => s.Definitions, definitionText));
settings.SetValue((TodoItemsCountSettings s) => s.Definitions, definitionText);

Assert.That(consumer.TodoItemsCounts.NotNull().Select(x => (x.Definition.ToString(), x.Count)), Is.EqualTo(new[]
{
Expand All @@ -52,7 +52,7 @@ public void TodoItemsCounts_WithNonMatchingName()
{
Test((consumer, settings) =>
{
RunGuarded(() => settings.SetValue((TodoItemsCountSettings s) => s.Definitions, "Todo\nNON_MATCHING"));
settings.SetValue((TodoItemsCountSettings s) => s.Definitions, "Todo\nNON_MATCHING");

Assert.That(consumer.TodoItemsCounts.NotNull().Select(x => (x.Definition.ToString(), x.Count)), Is.EqualTo(new[]
{
Expand All @@ -67,7 +67,7 @@ public void TodoItemsCounts_WithDuplicateDefinition()
{
Test((consumer, settings) =>
{
RunGuarded(() => settings.SetValue((TodoItemsCountSettings s) => s.Definitions, "Todo\nTodo"));
settings.SetValue((TodoItemsCountSettings s) => s.Definitions, "Todo\nTodo");

Assert.That(consumer.TodoItemsCounts.NotNull().Select(x => (x.Definition.ToString(), x.Count)), Is.EqualTo(new[]
{
Expand Down Expand Up @@ -115,8 +115,7 @@ public void TodoItemsCounts_ConsumerUpdateRequestSignal()
private void Test(Action<TestTodoItemsCountConsumer, IContextBoundSettingsStore> action)
{
var files = new[] { "Sample.cs", "Sample.xml" };

ExecuteWithinSettingsTransaction(settings =>
ExecuteWithinSettingsTransactionGuarded(TestLifetime, (_, settings) =>
{
WithSingleProject(
files.Select(x => GetTestDataFilePath2(x).FullPath),
Expand All @@ -126,12 +125,17 @@ private void Test(Action<TestTodoItemsCountConsumer, IContextBoundSettingsStore>
var consumer = ShellInstance.GetComponent<TestTodoItemsCountConsumer>();

action(consumer, settings);
});

// Disable to solve issues with TodoItemsCountProvider-updates during termination of
// the "settings transaction":
settings.SetValue((TodoItemsCountSettings s) => s.IsEnabled, false);
// Disable to solve issues with TodoItemsCountProvider-updates during termination of
// the "settings transaction":
//settings.SetValue((TodoItemsCountSettings s) => s.IsEnabled, false);
});
});
}

public override void TearDown()
{
RunWithAsyncBehaviorAllowed(() => { base.TearDown(); });
}
}
}
6 changes: 3 additions & 3 deletions Src/Roflcopter.Plugin.Tests/test/data/TodoItems/Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ public class Sample
{
// TODO

// TODO 1 before Important after
// TODO 2 before Important after
// TODO 3 before imPOrTaNt after
// TODO: 1 before Important after
// TODO: 2 before Important after
// TODO: 3 before imPOrTaNt after

// BUG: 1
// BUG: 2
Expand Down
2 changes: 1 addition & 1 deletion Src/Roflcopter.Plugin.Tests/test/data/TodoItems/Sample.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<root>
<!-- TODO in XML -->
<!-- TODO: in XML -->
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows.Input;
using JetBrains.Annotations;
using JetBrains.Application;
using JetBrains.Application.Parts;
using JetBrains.Application.Threading;
using JetBrains.Application.UI.Actions;
using JetBrains.Application.UI.ActionSystem.ActionBar;
Expand All @@ -21,7 +22,7 @@

namespace Roflcopter.Plugin.TodoItems.Presentation
{
[ShellComponent]
[ShellComponent(Instantiation.DemandAnyThreadSafe)]
[ExcludeFromCodeCoverage /* manually tested UI code */]
public class TodoItemsCountPresenter : IActionBarPatcher, ITodoItemsCountConsumer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Roflcopter.Plugin.TodoItems
{
[SolutionComponent(Instantiation.DemandAnyThreadSafe)] // TODO: Review Instantiation !!
[SolutionComponent(Instantiation.ContainerAsyncPrimaryThread)] // TODO: Review Instantiation !!
public class TodoItemsCountDefinitionsCachedSettingsReader : ICachedSettingsReader<IReadOnlyCollection<TodoItemsCountDefinition>>
{
private readonly ISettingsStore _settingsStore;
Expand Down
2 changes: 1 addition & 1 deletion Src/Roflcopter.Plugin/TodoItems/TodoItemsCountProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Roflcopter.Plugin.TodoItems
{
[SolutionComponent(Instantiation.LaterAsyncAnyThreadUnsafe)] // TODO: Review Instantiation !!
[SolutionComponent(Instantiation.ContainerAsyncPrimaryThread)] // TODO: Review Instantiation !!
public class TodoItemsCountProvider
{
private static readonly ILogger Logger = JetBrains.Util.Logging.Logger.GetLogger(typeof(TodoItemsCountProvider));
Expand Down

0 comments on commit 8143cd9

Please sign in to comment.