Skip to content

How to mock libplctag.NET #450

@timyhac

Description

@timyhac

@timyhac Is there a reason why this constructor of the Tag class was made internal? I would like to write test for custom Tag-classs that use the real Tag class.
And then pass a mock for the INative for local testing without a device for both the tag + any encoding or decoding.
But as the constructor is internal and the class no longer has an interface. This is now unnecessary complicated because the design ingores the open-closed principal.

I also don't understand why the ITag interface was deprecated and why the Tag class does not implement this interface. Could you please elaborate?

Originally posted by @sebastian-zitzelsberger in #406

Hi @sebastian-zitzelsberger - apologies if I am misinterpreting your query; to me it seems that the core requirement is to be able to mock the device you're connecting to - which is unrelated to #406 (hence why I've moved this conversation to a new issue).

The approach I would take is to develop the abstraction point within your application, and provide one class that consumes libplctag.NET, and another that provides the mocking behaviour. Something like this example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions