Пример #1
0
        public void Services_should_be_reused_among_calls_within_session()
        {
            client.Initiating("start ");
            client.Operation1("one ");
            client.Operation1("and again");
            client.Operation2("two ");
            client.Operation2("and two again");
            client.Terminating();
            var invocations = windsorContainer.Resolve <CollectingInterceptor>()
                              .AllInvocations
                              .GroupBy(i => i.InvocationTarget)
                              .ToArray();

            Assert.AreEqual(2, invocations.Length);
            var one = invocations[0].Key as One;
            var two = invocations[1].Key as Two;

            Assert.AreEqual("start one and again", one.Arg);
            Assert.AreEqual("two and two again", two.Arg);
        }
Пример #2
0
        public void Services_should_not_be_shared_between_two_subsequent_sessions()
        {
            client.Initiating("Client 1");
            client.Operation1(" Run Forrest run!");
            client.Terminating();
            client = CreateClient();
            client.Initiating("Client 2");
            client.Operation1(" welcomes you.");
            client.Terminating();
            var interceptor = windsorContainer.Resolve <CollectingInterceptor>();
            var invocations = interceptor
                              .AllInvocations
                              .GroupBy(i => i.InvocationTarget)
                              .ToArray();

            Assert.AreEqual(6, ServiceWithSession.InstanceCount);
            Assert.AreEqual(2, invocations.Length);
            var one1 = invocations[0].Key as One;
            var one2 = invocations[1].Key as One;

            Assert.AreEqual("Client 1 Run Forrest run!", one1.Arg);
            Assert.AreEqual("Client 2 welcomes you.", one2.Arg);
        }
		public void Services_should_not_be_shared_between_two_subsequent_sessions()
		{
			client.Initiating("Client 1");
			client.Operation1(" Run Forrest run!");
			client.Terminating();
			client = CreateClient();
			client.Initiating("Client 2");
			client.Operation1(" welcomes you.");
			client.Terminating();
			var interceptor = windsorContainer.GetService<CollectingInterceptor>();
			var invocations = interceptor
				.AllInvocations
				.GroupBy(i => i.InvocationTarget)
				.ToArray();

			Assert.AreEqual(6, ServiceWithSession.InstanceCount);
			Assert.AreEqual(2, invocations.Length);
			var one1 = invocations[0].Key as One;
			var one2 = invocations[1].Key as One;
			Assert.AreEqual("Client 1 Run Forrest run!", one1.Arg);
			Assert.AreEqual("Client 2 welcomes you.", one2.Arg);
		}