Skip to content

Commit

Permalink
Rename startup attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Jandini committed Oct 16, 2023
1 parent 97211f4 commit 8153f75
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace KiBoards
{
internal static class TestExtensions
internal static class KiBoardsTestExtensions
{
public static string ComputeMD5(this string value) => BitConverter.ToString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(value))).Replace("-", "").ToLower();
public static void WriteMessage(this IMessageSink messageSink, string message) => messageSink.OnMessage(new DiagnosticMessage(message));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[AttributeUsage(AttributeTargets.Assembly)]
public class TestStartupAttribute : Attribute
public class KiboardsTestStartupAttribute : Attribute
{
public string ClassName { get; set; }

public TestStartupAttribute(string className)
public KiboardsTestStartupAttribute(string className)
{
ClassName = className;
}
Expand Down
4 changes: 2 additions & 2 deletions src/KiBoards.Xunit/Services/KiBoardsTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public KiBoardsTestRunner(IMessageSink messageSink)
Variables = new Dictionary<string, string>()
};

var startupAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetCustomAttribute<TestStartupAttribute>() != null).ToArray();
var startupAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetCustomAttribute<KiboardsTestStartupAttribute>() != null).ToArray();
foreach (var assembly in startupAssemblies)
Startup(assembly, messageSink);

Expand Down Expand Up @@ -74,7 +74,7 @@ private void Startup(Assembly assembly, IMessageSink messageSink)
{
try
{
var startup = assembly.GetCustomAttribute<TestStartupAttribute>();
var startup = assembly.GetCustomAttribute<KiboardsTestStartupAttribute>();
Type type = assembly.GetType(startup.ClassName);

if (type != null)
Expand Down
6 changes: 1 addition & 5 deletions src/KiBoards.Xunit/TestFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public TestFrameworkExecutor(AssemblyName assemblyName, ISourceInformationProvid
{
_testRunner = testRunner;
_diagnosticMessageSink = diagnosticMessageSink;
}


}

protected override async void RunTestCases(IEnumerable<IXunitTestCase> testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
{
Expand All @@ -53,7 +51,6 @@ protected override async void RunTestCases(IEnumerable<IXunitTestCase> testCases
}



private class TestAssemblyRunner : XunitTestAssemblyRunner
{
private readonly KiBoardsTestRunner _testRunner;
Expand Down Expand Up @@ -107,7 +104,6 @@ protected override Task<RunSummary> RunTestMethodAsync(ITestMethod testMethod, I
}



private class TestResultBus : IMessageBus
{
private readonly IMessageBus _messageBus;
Expand Down
2 changes: 1 addition & 1 deletion src/KiBoards/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Reflection;
using Xunit.Abstractions;

[assembly: TestStartup("KiBoards.Startup")]
[assembly: KiboardsTestStartup("KiBoards.Startup")]

namespace KiBoards
{
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleTest/Simple_Must.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[assembly: KiBoardsSavedObjects()]
[assembly: KiboardsTestStartup("SimpleTest.Startup")]
[assembly: TestFramework("KiBoards.TestFramework", "KiBoards.Xunit")]
[assembly: TestStartup("SimpleTest.Startup")]

namespace SimpleTest
{
public class Simple_Must
{
[Theory]
[InlineData(1, 2)]
[InlineData(0, 2)]
public void Not_DivideByZero(int a, int b)
{
var c = 1 / b;
Expand Down

0 comments on commit 8153f75

Please sign in to comment.