/// <summary> /// Creates a <see cref="WuApiController"/> which uses the given Interfaces to search, download and install updates. /// </summary> /// <param name="session">Session to be used.</param> /// <param name="updateCollectionFactory">Factory to create <see cref="IUpdateCollection"/>s.</param> /// <param name="systemInfo">System informations about the OS enviroment.</param> public WuApiController(IUpdateSession session, UpdateCollectionFactory updateCollectionFactory, ISystemInfo systemInfo) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (updateCollectionFactory == null) { throw new ArgumentNullException(nameof(updateCollectionFactory)); } if (systemInfo == null) { throw new ArgumentNullException(nameof(systemInfo)); } UpdateSession = session; UpdateSession.ClientApplicationID = this.GetType().FullName; UpdateSearcher = session.CreateUpdateSearcher(); UpdateDownloader = session.CreateUpdateDownloader(); UpdateInstaller = session.CreateUpdateInstaller(); UpdateCollectionFactory = updateCollectionFactory; SystemInfo = systemInfo; StateTransitions = SetupStateTransitions(); EnterState((SystemInfo.IsRebootRequired()) ? (WuProcessState) new WuStateRebootRequired() : new WuStateReady()); Log.Info("Initial state: " + _currentState.GetType().Name); if (Log.IsDebugEnabled) { OnStateChanged += (s, e) => { Log.Debug($"Event {nameof(OnStateChanged)} fired: {e.ToString()}"); }; OnAsyncOperationCompleted += (s, e) => { Log.Debug($"Event {nameof(OnAsyncOperationCompleted)} fired: {e.ToString()}"); }; OnProgressChanged += (s, e) => { Log.Debug($"Event {nameof(OnProgressChanged)} fired: {e.ToString()}"); }; } }
public void Should_CreateNewObjects_When_RequestInstance() { UpdateCollectionFactory factory = new UpdateCollectionFactory(); IUpdateCollection coll1 = factory.GetInstance(); IUpdateCollection coll2 = factory.GetInstance(); Assert.IsNotNull(coll1); Assert.IsNotNull(coll2); Assert.AreNotSame(coll1, coll2); }