Replies: 2 comments
-
The reason they're different is because data generators can be invoked multiple times if used on both the class and method level. Whereas class constructors are only ever invoked once.
Yep the object bag exists for that reason, to store whatever you like to use however you like. Are you experiencing any issues? |
Beta Was this translation helpful? Give feedback.
-
No everything fine. I am just new to developing for TUnit and wanted to be sure, there are many options for this, e.g. using some kind of event. |
Beta Was this translation helpful? Give feedback.
-
I am currently writing two classes. One is inheriting from NonTypedDataSourceGeneratorAttribute and the other is implementing IClassConstructor.
In both cases when I try to access the TestBuilderContext it looks different:
vs
Should they not look the same?
On a side note, I am looking at your example of DependencyInjectionClassConstructor and want to combine the logic also for a data source generator.
I am trying something with AutoFixture, but lets use the scope of your example. In the end it should be possible to use the classconstructor and/or the datasource generator. So both must check if the scope is already in the ObjectBag otherwise they insert it, so the second one can get the value.
Is this the right approach to pass something from datasource generator to classconstructor. (To my suprise this is the order from debugging, I expected it the other way round)
Beta Was this translation helpful? Give feedback.
All reactions