Question background:
I am trying to set the constructor of the class I am trying to create an object of through the use of Unity but currently am running into this error:
The error:
Result Message: Test method ABCTestProject.TFStests.Check_Interface_CheckOut_Method threw exception: System.InvalidOperationException: The type ABC.Tools.VersionControl.TfsVersionControl.TfsVcPromotionManager does not have a constructor that takes the parameters (ITfsVcQaCheckoutWorker, ITfsVcQaCheckinWorker, VersionControlServer).
I believe this is something I am miss setting when registering the unity object as the TfsPromotion Manager class does expect the objects being passed to it.
The code:
Here's the Unity creation class:
internal static ITfsVcPromotionManager CreateUnityObjects(VersionControlServer tfServer)
{
var unityContainer = new UnityContainer();
var test = new TfsVcQaCheckoutWorker(tfServer);
InjectionConstructor injectionConstructor = new InjectionConstructor(test);
var test1 = new TfsVcQaCheckinWorker();
InjectionConstructor injectionConstructor1 = new InjectionConstructor(test1);
unityContainer.RegisterType<ITfsVcPromotionManager, TfsVcPromotionManager>(new InjectionConstructor(new ResolvedParameter(typeof(ITfsVcQaCheckoutWorker)), new ResolvedParameter(typeof(ITfsVcQaCheckinWorker)), new ResolvedParameter(typeof(VersionControlServer))));
return unityContainer.Resolve<ITfsVcPromotionManager>();
}
The TfsPromotionManager constructor:
internal TfsVcPromotionManager(ITfsVcQaCheckoutWorker checkOutWorker, ITfsVcQaCheckinWorker checkInWorker, VersionControlServer tfServer)
{
_checkoutWorker = checkOutWorker;
}