Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to work with enum parameters and return values #31

Open
Dzoay opened this issue Jul 3, 2018 · 2 comments
Open

How to work with enum parameters and return values #31

Dzoay opened this issue Jul 3, 2018 · 2 comments

Comments

@Dzoay
Copy link

Dzoay commented Jul 3, 2018

I have an interface that I would like to duck type that returns enum types and takes enum types as parameters.
e.g.

public enum Status
{
    Started,
    Running,
    Finished,
}

public class Calculator
{
    public Status Calculate(CalculationType calculationType)
    {
        // ... some very complex calculations
        return Status.Finished;
    }
}

When attempting to call functions like Calculate with an impromtu interface created using ActLike<T> I receiving binding exceptions.
I noticed in the InterfaceDictionaryWrappedTest() mapping int to TestEnum works well but I cannot find a way to create an impromtu interface for something like the example above.
Is there a way to do this?

@jbtule
Copy link
Member

jbtule commented Jul 3, 2018

I'm not aware of any problems with enums, can you make do a pull request with a new failing unit test reproducing your error?

@Dzoay
Copy link
Author

Dzoay commented Jul 4, 2018

Submitted #32 with a failing test - also passing tests with what I managed to achieve. I am interested in the most convenient way to work with enum parameters where the type cannot be referenced statically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants