Exemple #1
0
        public void OnChildClosedRemovesArgumentFromListOfChildren()
        {
            // given
            IOpenKitComposite target = CreateOpenKit().Build();

            var childObjectOne = Substitute.For <IOpenKitObject>();
            var childObjectTwo = Substitute.For <IOpenKitObject>();

            target.StoreChildInList(childObjectOne);
            target.StoreChildInList(childObjectTwo);

            // when
            target.OnChildClosed(childObjectOne);

            // then
            var childObjects = target.GetCopyOfChildObjects();

            Assert.That(childObjects.Count, Is.EqualTo(1));
            Assert.That(childObjects[0], Is.SameAs(childObjectTwo));

            // when
            target.OnChildClosed(childObjectTwo);

            // then
            Assert.That(target.GetCopyOfChildObjects(), Is.Empty);
        }
Exemple #2
0
        public void CreateSessionWithoutIpAddsNewlyCreatedSessionToListOfChildren()
        {
            // given
            var target = CreateOpenKit().Build();
            IOpenKitComposite targetComposite = target;

            // when
            var sessionOne = target.CreateSession();

            // then
            var childObjects = targetComposite.GetCopyOfChildObjects();

            Assert.That(sessionOne, Is.Not.Null);
            Assert.That(childObjects.Count, Is.EqualTo(1));
            Assert.That(childObjects[0], Is.SameAs(sessionOne));

            // when
            var sessionTwo = target.CreateSession();

            // then
            childObjects = targetComposite.GetCopyOfChildObjects();
            Assert.That(sessionTwo, Is.Not.Null);
            Assert.That(childObjects.Count, Is.EqualTo(2));
            Assert.That(childObjects[0], Is.SameAs(sessionOne));
            Assert.That(childObjects[1], Is.SameAs(sessionTwo));
        }
        public void End()
        {
            if (logger.IsDebugEnabled)
            {
                logger.Debug($"{this} End()");
            }

            lock (lockObject)
            {
                if (isFinished)
                {
                    return;
                }

                isFinished = true;
            }

            var childObjects = ThisComposite.GetCopyOfChildObjects();

            foreach (var childObject in childObjects)
            {
                if (childObject is ISessionInternals childSession)
                {
                    childSession.End(childSession == currentSession);
                }
                else
                {
                    childObject.Dispose();
                }
            }

            parent.OnChildClosed(this);
            sessionWatchdog.RemoveFromSplitByTimeout(this);
        }
        public void OnChildClosedRemovesChildFromList()
        {
            // given
            IOpenKitComposite target = CreateStubAction();
            var childObject          = Substitute.For <IOpenKitObject>();

            target.StoreChildInList(childObject);

            // when
            target.OnChildClosed(childObject);

            // then
            Assert.That(target.GetCopyOfChildObjects(), Is.Empty);
        }
        public void TraceWebRequestAttachesWebRequestTracerAsChildObject()
        {
            // given
            var target = CreateStubAction();
            IOpenKitComposite targetComposite = target;

            // when
            var obtained = target.TraceWebRequest("http://example.com/pages/");

            // then
            var childObjects = targetComposite.GetCopyOfChildObjects();

            Assert.That(childObjects.Count, Is.EqualTo(1));
            Assert.That(childObjects[0], Is.SameAs(obtained));
        }
Exemple #6
0
        public void EnterActionAddsLeafActionToListOfChildObjects()
        {
            // given
            var target = CreateRootAction();
            IOpenKitComposite targetComposite = target;

            // when
            var obtained = target.EnterAction(ChildActionName);

            // then
            var childObjects = targetComposite.GetCopyOfChildObjects();

            Assert.That(childObjects.Count, Is.EqualTo(1));
            Assert.That(childObjects[0], Is.SameAs(obtained));
        }