Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ static bool TryCastWithDefaultValue<TValue>(object?[] values, int index, TValue

sb.AppendXmlSummary($"Set up the mock of <see cref=\"{escapedClassName}\" />.", "\t");
sb.Append("\tinternal interface IMockSetupFor").Append(name);
if (!hasStaticMembers)
if (!hasStaticMembers && !hasStaticEvents)
{
sb.Append(" : global::Mockolate.Setup.IMockSetup<").Append(@class.ClassFullName).Append(">").AppendLine();
}
Expand Down Expand Up @@ -1235,7 +1235,7 @@ static bool TryCastWithDefaultValue<TValue>(object?[] values, int index, TValue

sb.AppendXmlSummary($"Verify interactions with the mock of <see cref=\"{escapedClassName}\" />.", "\t");
sb.Append("\tinternal interface IMockVerifyFor").Append(name);
if (!hasStaticMembers)
if (!hasStaticMembers && !hasStaticEvents)
{
sb.Append(" : global::Mockolate.Verify.IMockVerify<").Append(@class.ClassFullName).Append(">").AppendLine();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,32 @@ await That(result.Sources["Mock.IMyService__IMyServiceBase1__IMyServiceBase2.g.c
.Contains("long global::MyCode.IMyServiceBase2.Value()").Once();
}

[Fact]
public async Task ParameterNamedI_ShouldNotCollideWithVerifyLambdaVariable()
{
GeneratorResult result = Generator
.Run("""
using Mockolate;

namespace MyCode;

public class Program
{
public static void Main(string[] args)
{
_ = IMyService.CreateMock();
}
}

public interface IMyService
{
void Do(int i, string s);
}
""");

await That(result.Diagnostics).IsEmpty();
}

[Fact]
public async Task ShouldImplementAllMethodsFromInterfaces()
{
Expand Down Expand Up @@ -1249,6 +1275,33 @@ await That(result.Sources["Mock.IMyService.g.cs"])
""").IgnoringNewlineStyle();
}

[Fact]
public async Task StaticAbstractEventOnly_ShouldCompile()
{
GeneratorResult result = Generator
.Run("""
using System;
using Mockolate;

namespace MyCode;

public class Program
{
public static void Main(string[] args)
{
_ = IMyService.CreateMock();
}
}

public interface IMyService
{
static abstract event Action<int> AbstractStaticEvent;
}
""");

await That(result.Diagnostics).IsEmpty();
}

[Fact]
public async Task VirtualMethodOverride_WithConstrainedGeneric_ShouldNotRepeatConstraints()
{
Expand Down Expand Up @@ -1290,32 +1343,6 @@ public override bool MyMethod<T>(T entity)
.DoesNotContain("public override bool MyMethod<T>(T entity)\n\t\t\twhere T :").IgnoringNewlineStyle()
.Because("CS0460: constraints on override methods are inherited from the base method");
}

[Fact]
public async Task ParameterNamedI_ShouldNotCollideWithVerifyLambdaVariable()
{
GeneratorResult result = Generator
.Run("""
using Mockolate;

namespace MyCode;

public class Program
{
public static void Main(string[] args)
{
_ = IMyService.CreateMock();
}
}

public interface IMyService
{
void Do(int i, string s);
}
""");

await That(result.Diagnostics).IsEmpty();
}
}
}
}