public SelfUpdateService(bool isSelfUpdate, Package updatePackage) { Mock <ISelfUpdateService> mock = new Mock <ISelfUpdateService>(); mock .SetupGet(s => s.IsSelfUpdate) .Callback(() => IsSelfUpdateCalled.Increment()) .Returns(isSelfUpdate); mock .Setup(s => s.Update(It.Is <IPackage>(p => p == UpdatePackages[UpdateCalled]))) .Callback(() => UpdateCalled.Increment()); mock .Setup(s => s.RunNewInstance(It.Is <IPackage>(p => p == UpdatePackages[RunNewInstanceCalled]))) .Callback(() => RunNewInstanceCalled.Increment()); if (updatePackage != null) { UpdatePackages.Add(updatePackage.Object); } Object = mock.Object; }