cqrs - How to test order of parameters C# -
i working on cqrs system.
it uses commands , events standard practice. commands , events .net classes these classes contain number of id's properties , these id's guids.
this leads problem when constructing classes. there big if not huge risk on team phone call constructor parameters in wrong order. can imagine how simple problem devastating i.e. orderid assigned customerid , vice versa.
so looking ideas how solve this.
i have ideas myself.
make seperate type each id. i.e. replace guid lots of types. obvious oo solution. not number of reasons. consistent naming , unittesting: if name our id's id. can potentially test parameterlist in caller , callee same (or similar). , ignore cases when utilize guid.newguid(). test not simple though. parameters of method called, quite easy parameter list using reflection or mono.reflection. caller matter. variables in method might optimized away instance. testing caller need other reflection, along lines of stylecop instance.all in not sold on either idea, , simpler or perhaps ready made solution ?
separate type each id solution don't also.
unit testing method calls hard problem. consistent naming good.
in sentiment many parameters in commands/events first signal wrong. maybe command responsible many things or parameters can deliver via infrastructure (like current user identity).
edit: if can create sure there no order , client (for example) same id (i think guids safe assumption) can verify both exists , if somewhere mix these 2 values there error in runtime, error spotted easily.
c# cqrs
No comments:
Post a Comment