* Update gitignore * Move csproj * Update project references * Update solutions * Update build scripts * Tests used to share editorconfig with projects in src * Fix broken tests. * Stop copying around .editorconfig merged root one with linting * csharp_style_expression_bodied -> suggestion * Move StyleCop rulesets to matching directories and update shared build properties * Remove legacy build files, update NuGet.cofig and solution files * Restore myget source * Clean up .gitignore * Update .gitignore * Move new test classes to tests after merge * Gitignore + nuget config * Move new test Co-authored-by: Ronald Barendse <ronald@barend.se>
60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using System;
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Events;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Scoping
|
|
{
|
|
[TestFixture]
|
|
public class EventNameExtractorTests
|
|
{
|
|
[Test]
|
|
public void Find_Event_Ing()
|
|
{
|
|
Attempt<EventNameExtractorResult> found = EventNameExtractor.FindEvent(this, new SaveEventArgs<string>("test"), EventNameExtractor.MatchIngNames);
|
|
Assert.IsTrue(found.Success);
|
|
Assert.AreEqual("FoundMe", found.Result.Name);
|
|
}
|
|
|
|
[Test]
|
|
public void Find_Event_Non_Ing()
|
|
{
|
|
Attempt<EventNameExtractorResult> found = EventNameExtractor.FindEvent(this, new SaveEventArgs<string>("test"), EventNameExtractor.MatchNonIngNames);
|
|
Assert.IsTrue(found.Success);
|
|
Assert.AreEqual("FindingMe", found.Result.Name);
|
|
}
|
|
|
|
[Test]
|
|
public void Ambiguous_Match()
|
|
{
|
|
Attempt<EventNameExtractorResult> found = EventNameExtractor.FindEvent(this, new SaveEventArgs<int>(0), EventNameExtractor.MatchIngNames);
|
|
Assert.IsFalse(found.Success);
|
|
Assert.AreEqual(EventNameExtractorError.Ambiguous, found.Result.Error);
|
|
}
|
|
|
|
[Test]
|
|
public void No_Match()
|
|
{
|
|
Attempt<EventNameExtractorResult> found = EventNameExtractor.FindEvent(this, new SaveEventArgs<double>(0), EventNameExtractor.MatchIngNames);
|
|
Assert.IsFalse(found.Success);
|
|
Assert.AreEqual(EventNameExtractorError.NoneFound, found.Result.Error);
|
|
}
|
|
|
|
public static event EventHandler<SaveEventArgs<string>> FindingMe;
|
|
|
|
public static event EventHandler<SaveEventArgs<string>> FoundMe;
|
|
|
|
// will lead to ambiguous matches
|
|
public static event EventHandler<SaveEventArgs<int>> SavingThis;
|
|
|
|
public static event EventHandler<SaveEventArgs<int>> SavedThis;
|
|
|
|
public static event EventHandler<SaveEventArgs<int>> SavingThat;
|
|
|
|
public static event EventHandler<SaveEventArgs<int>> SavedThat;
|
|
}
|
|
}
|