public void Stop() { // Add 4 services: // - Service 1: no dependencies // - Service 2: Depends on Service 1 // - Service 3: Depends on Service 1 // - Service 4: Depends on Service 2 and Service 3 // // startup order should be: // Service 1 // Service 2 / 3 // Service 4 var stopOrder = new List <KernelService>(); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); Action <KernelService> storeAction = stopOrder.Add; var testMock1 = new KernelService1(service => { }, storeAction, systemDiagnostics); var testMock2 = new KernelService2(service => { }, storeAction, systemDiagnostics); var testMock3 = new KernelService3(service => { }, storeAction, systemDiagnostics); var testMock4 = new KernelService4(service => { }, storeAction, systemDiagnostics); var kernel = new Kernel( () => { }, systemDiagnostics); kernel.Install(testMock1); kernel.Install(testMock2); kernel.Install(testMock3); kernel.Install(testMock4); kernel.Start(); kernel.Shutdown(); Assert.AreEqual(4, stopOrder.Count); Assert.That( stopOrder, Is.EquivalentTo(new List <KernelService> { testMock4, testMock3, testMock2, testMock1, })); }
public void InstallServiceAsDependentLast() { var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var kernelTestMock1 = new KernelService1( service => { }, service => { }, systemDiagnostics); var kernelTestMock2 = new KernelService2( service => { }, service => { }, systemDiagnostics); var kernel = new Kernel( () => { }, systemDiagnostics); kernel.Install(kernelTestMock2); kernel.Install(kernelTestMock1); Assert.AreSame(kernelTestMock1, kernelTestMock2.Connection); }
public void Stop() { // Add 4 services: // - Service 1: no dependencies // - Service 2: Depends on Service 1 // - Service 3: Depends on Service 1 // - Service 4: Depends on Service 2 and Service 3 // // startup order should be: // Service 1 // Service 2 / 3 // Service 4 var stopOrder = new List<KernelService>(); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); Action<KernelService> storeAction = stopOrder.Add; var testMock1 = new KernelService1(service => { }, storeAction, systemDiagnostics); var testMock2 = new KernelService2(service => { }, storeAction, systemDiagnostics); var testMock3 = new KernelService3(service => { }, storeAction, systemDiagnostics); var testMock4 = new KernelService4(service => { }, storeAction, systemDiagnostics); var kernel = new Kernel( () => { }, systemDiagnostics); kernel.Install(testMock1); kernel.Install(testMock2); kernel.Install(testMock3); kernel.Install(testMock4); kernel.Start(); kernel.Shutdown(); Assert.AreEqual(4, stopOrder.Count); Assert.That( stopOrder, Is.EquivalentTo(new List<KernelService> { testMock4, testMock3, testMock2, testMock1, })); }