コード例 #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestAddUninitedSiblingInStart()
        {
            CompositeService parent  = new CompositeService("parent");
            BreakableService sibling = new BreakableService();

            parent.AddService(new TestCompositeService.AddSiblingService(parent, sibling, Service.STATE
                                                                         .Started));
            parent.Init(new Configuration());
            AssertInState(Service.STATE.Notinited, sibling);
            parent.Start();
            parent.Stop();
            Assert.Equal("Incorrect number of services", 2, parent.GetServices
                             ().Count);
        }
コード例 #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestAddStartedChildBeforeInit()
        {
            CompositeService parent = new CompositeService("parent");
            BreakableService child  = new BreakableService();

            child.Init(new Configuration());
            child.Start();
            TestCompositeService.AddSiblingService.AddChildToService(parent, child);
            try
            {
                parent.Init(new Configuration());
                NUnit.Framework.Assert.Fail("Expected an exception, got " + parent);
            }
            catch (ServiceStateException)
            {
            }
            //expected
            parent.Stop();
        }
コード例 #3
0
        /// <exception cref="System.Exception"/>
        public virtual void TestAddUninitedSiblingInInit()
        {
            CompositeService parent  = new CompositeService("parent");
            BreakableService sibling = new BreakableService();

            parent.AddService(new TestCompositeService.AddSiblingService(parent, sibling, Service.STATE
                                                                         .Inited));
            parent.Init(new Configuration());
            try
            {
                parent.Start();
                NUnit.Framework.Assert.Fail("Expected an exception, got " + parent);
            }
            catch (ServiceStateException)
            {
            }
            //expected
            parent.Stop();
            Assert.Equal("Incorrect number of services", 2, parent.GetServices
                             ().Count);
        }