Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
Misc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Abrynos committed Aug 13, 2021
1 parent b95f004 commit 5d70fe8
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 214 deletions.
1 change: 1 addition & 0 deletions Implement.Net.Tests/AbstractTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
namespace Implement.Net.Tests {
public abstract class AbstractTest {
protected GenerationOptions Options { get; } = new ();

protected TypeFactory TypeFactory { get; } = new ();

protected Type CreateType<TInterface>(GenerationOptions? options = null) where TInterface : class => TypeFactory.CreateType<TInterface>(options ?? Options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public abstract class AbstractGeneratedInstanceTest : AbstractTest {

protected DefaultHandler DefaultHandler { get; } = new ();

protected static TInterface CreateInstance<TInterface>(Type type, IDynamicHandler? handler = null) where TInterface : class => (Activator.CreateInstance(type, handler ?? new DefaultHandler()) as TInterface)!;

protected TInterface CreateInstance<TInterface>(IDynamicHandler? handler = null) where TInterface : class => (Activator.CreateInstance(CreateType<TInterface>(), handler ?? new DefaultHandler()) as TInterface)!;

protected static TInterface CreateInstance<TInterface>(Type type, IDynamicHandler? handler = null) where TInterface : class => (Activator.CreateInstance(type, handler ?? new DefaultHandler()) as TInterface)!;

protected static CallbackHandler.EventDelegate EventModifier(bool success, Action additionalAction) => EventModifier(success, (_, _, _) => additionalAction.Invoke());

protected static CallbackHandler.EventDelegate EventModifier(bool success, Action<Type, string, object?>? additionalAction = null) => (t, n, v) => {
Expand Down
8 changes: 4 additions & 4 deletions Implement.Net.Tests/GeneratedClassTests/ObjectMethodsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,20 @@ public void ToStringIgnored() {
}

private sealed class ObjectMethodHandler : DefaultHandler {
private readonly Action FinalizeAction;

internal bool EqualsCalled { get; private set; }

internal bool GetHashCodeCalled { get; private set; }

internal bool ToStringCalled { get; private set; }

private readonly Action FinalizeAction;

internal ObjectMethodHandler() : this(() => { }) { }

internal ObjectMethodHandler(Action finalizeAction) => FinalizeAction = finalizeAction;

~ObjectMethodHandler() => FinalizeAction.Invoke();

public override bool Equals(object? obj) {
EqualsCalled = true;

Expand All @@ -202,8 +204,6 @@ public override string ToString() {

return string.Empty;
}

~ObjectMethodHandler() => FinalizeAction.Invoke();
}
}
}
Loading

0 comments on commit 5d70fe8

Please sign in to comment.