项目结构调整

This commit is contained in:
艾竹
2023-04-16 20:11:40 +08:00
parent cbfbf96033
commit 81f91f3f35
2124 changed files with 218 additions and 5516 deletions

View File

@@ -0,0 +1,54 @@
namespace Fluent.Tests.Internal
{
using Fluent.Internal;
using NUnit.Framework;
[TestFixture]
public class ScopeGuardTests
{
[Test]
public void IsActive_Marker_Should_Change_On_Dispose()
{
var guard = new ScopeGuard();
Assert.That(guard.IsActive, Is.False);
guard.Start();
Assert.That(guard.IsActive, Is.True);
guard.Dispose();
Assert.That(guard.IsActive, Is.False);
Assert.That(() => guard.Dispose(), Throws.Nothing);
Assert.That(guard.IsActive, Is.False);
}
[Test]
public void Actions_Should_Be_Called()
{
var entryActionCallCount = 0;
void EntryAction() => ++entryActionCallCount;
var disposeActionCallCount = 0;
void DisposeAction() => ++disposeActionCallCount;
var guard = new ScopeGuard(EntryAction, DisposeAction).Start();
Assert.That(entryActionCallCount, Is.EqualTo(1));
Assert.That(disposeActionCallCount, Is.EqualTo(0));
guard.Dispose();
Assert.That(entryActionCallCount, Is.EqualTo(1));
Assert.That(disposeActionCallCount, Is.EqualTo(1));
guard.Dispose();
Assert.That(entryActionCallCount, Is.EqualTo(1));
Assert.That(disposeActionCallCount, Is.EqualTo(1));
}
}
}

View File

@@ -0,0 +1,55 @@
namespace Fluent.Tests.Internal
{
using System.Windows.Controls;
using Fluent.Internal;
using Fluent.Tests.TestClasses;
using NUnit.Framework;
[TestFixture]
public class WhenLoadedTests
{
[Test]
public void Action_Should_Be_Called_When_Already_Loaded()
{
var control = new Control();
var loadedActionCallCount = 0;
using (new TestRibbonWindow(control))
{
control.WhenLoaded(x => ++loadedActionCallCount);
Assert.That(loadedActionCallCount, Is.EqualTo(1));
}
// Check that only one loaded event triggers the action
using (new TestRibbonWindow(control))
{
Assert.That(loadedActionCallCount, Is.EqualTo(1));
}
}
[Test]
public void Action_Should_Be_Called_When_Loaded_Later()
{
var control = new Control();
var loadedActionCallCount = 0;
control.WhenLoaded(x => ++loadedActionCallCount);
Assert.That(loadedActionCallCount, Is.EqualTo(0));
using (new TestRibbonWindow(control))
{
Assert.That(loadedActionCallCount, Is.EqualTo(1));
}
// Check that only one loaded event triggers the action
using (new TestRibbonWindow(control))
{
Assert.That(loadedActionCallCount, Is.EqualTo(1));
}
}
}
}