public void TestAddOpenSessionEvent()
        {
            ShardImpl shard = new ShardImpl(new ShardId(1), Stub <ISessionFactoryImplementor>()); //new SessionFactoryDefaultMock()

            try
            {
                shard.AddOpenSessionEvent(null);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }
            IOpenSessionEvent ose = Stub <IOpenSessionEvent>(); //new OpenSessionEventDefaultMock()

            shard.AddOpenSessionEvent(ose);
            Assert.IsNotNull(shard.GetOpenSessionEvents());
            Assert.AreEqual(1, shard.GetOpenSessionEvents().Count);  //.size()
            //Assert.AreSame(ose, shard.GetOpenSessionEvents().Find(0));//.get(0)

            // now add another and make sure it is added to the end
            IOpenSessionEvent anotherOse = Stub <IOpenSessionEvent>();

            shard.AddOpenSessionEvent(anotherOse);
            Assert.IsNotNull(shard.GetOpenSessionEvents());
            Assert.AreEqual(2, shard.GetOpenSessionEvents().Count);  //.size()
            //Assert.AreSame(ose, shard.GetOpenSessionEvents().get(0));
            //Assert.AreSame(anotherOse, shard.GetOpenSessionEvents().get(1));
        }
        public void TestAddQueryEvent()
        {
            ShardImpl shard = new ShardImpl(new ShardId(1), Stub <ISessionFactoryImplementor>());

            try {
                shard.AddQueryEvent(null, null);
                Assert.Fail("expected npe");
            } catch (NullReferenceException npe) {
                // good
            }

            QueryId queryId = new QueryId(1);

            try {
                shard.AddQueryEvent(queryId, null);
                Assert.Fail("expected npe");
            } catch (NullReferenceException npe) {
                // good
            }

            IQueryEvent qe = Stub <IQueryEvent>();

            try {
                shard.AddQueryEvent(null, qe);
                Assert.Fail("expected npe");
            } catch (NullReferenceException npe) {
                // good
            }

            shard.AddQueryEvent(queryId, qe);
            //assertNotNull(shard.getQueryEventMap());
            //assertEquals(1, shard.getQueryEventMap().size());
            //assertEquals(1, shard.getQueryEventMap().get(queryId).size());
            //assertSame(qe, shard.getQueryEventMap().get(queryId).get(0));

            // now add another event to the same query
            IQueryEvent anotherQe = Stub <IQueryEvent>();

            shard.AddQueryEvent(queryId, anotherQe);
            //assertNotNull(shard.getQueryEventMap());
            //assertEquals(1, shard.getQueryEventMap().size());
            //assertEquals(2, shard.getQueryEventMap().get(queryId).size());
            //assertSame(qe, shard.getQueryEventMap().get(queryId).get(0));
            //assertSame(anotherQe, shard.getQueryEventMap().get(queryId).get(1));

            // now add an event to a different query
            QueryId     anotherQueryId = new QueryId(3);
            IQueryEvent yetAnotherQe   = Stub <IQueryEvent>();

            shard.AddQueryEvent(anotherQueryId, yetAnotherQe);
            //assertNotNull(shard.getQueryEventMap());
            //assertEquals(2, shard.getQueryEventMap().size());
            //assertEquals(2, shard.getQueryEventMap().get(queryId).size());
            //assertSame(qe, shard.getQueryEventMap().get(queryId).get(0));
            //assertSame(anotherQe, shard.getQueryEventMap().get(queryId).get(1));
            //assertEquals(1, shard.getQueryEventMap().get(anotherQueryId).size());
            //assertSame(yetAnotherQe, shard.getQueryEventMap().get(anotherQueryId).get(0));
        }
		public void EstablishSessionReturnsNewSessionOnFirstCall()
		{
			var shardedSessionImplementor = Stub<IShardedSessionImplementor>();
			var shard = new ShardImpl(
				shardedSessionImplementor,
				new ShardMetadataImpl(new ShardId(1), Stub<ISessionFactoryImplementor>()));

			shardedSessionImplementor.Expect(x => x.EstablishFor(shard)).Return(Stub<ISession>());

			var session = shard.EstablishSession();
			shardedSessionImplementor.VerifyAllExpectations();
			Assert.That(session, Is.Not.Null, "First establish creates new session");
		}
        public void EstablishSessionReturnsNewSessionOnFirstCall()
        {
            var shardedSessionImplementor = Substitute.For <IShardedSessionImplementor>();
            var shard = new ShardImpl(
                shardedSessionImplementor,
                new ShardMetadataImpl(new ShardId(1), Substitute.For <ISessionFactoryImplementor>()));

            shardedSessionImplementor.EstablishFor(shard).Returns(Substitute.For <ISession>());

            var session = shard.EstablishSession();

            Assert.That(session, Is.Not.Null, "First establish creates new session");
        }
        public void EstablishSessionReturnsExistingSessionOnNextCall()
        {
            var shardedSessionImplementor = Substitute.For <IShardedSessionImplementor>();
            var shard = new ShardImpl(
                shardedSessionImplementor,
                new ShardMetadataImpl(new ShardId(1), Substitute.For <ISessionFactoryImplementor>()));

            shardedSessionImplementor.EstablishFor(shard).Returns(Substitute.For <ISession>());

            var session  = shard.EstablishSession();
            var session2 = shard.EstablishSession();

            Assert.That(session2, Is.SameAs(session), "Next establish returns existing session");
        }
        public void EstablishSessionReturnsNewSessionOnFirstCall()
        {
            var shardedSessionImplementor = Stub <IShardedSessionImplementor>();
            var shard = new ShardImpl(
                shardedSessionImplementor,
                new ShardMetadataImpl(new ShardId(1), Stub <ISessionFactoryImplementor>()));

            shardedSessionImplementor.Expect(x => x.EstablishFor(shard)).Return(Stub <ISession>());

            var session = shard.EstablishSession();

            shardedSessionImplementor.VerifyAllExpectations();
            Assert.That(session, Is.Not.Null, "First establish creates new session");
        }
		public void EstablishSessionReturnsExistingSessionOnNextCall()
		{
			var shardedSessionImplementor = Stub<IShardedSessionImplementor>();
			var shard = new ShardImpl(
				shardedSessionImplementor,
				new ShardMetadataImpl(new ShardId(1), Stub<ISessionFactoryImplementor>()));

			shardedSessionImplementor.Expect(x => x.EstablishFor(shard)).Return(Stub<ISession>());

			var session = shard.EstablishSession();
			var session2 = shard.EstablishSession();
			Assert.That(session2, Is.SameAs(session), "Next establish returns existing session");

			shardedSessionImplementor.VerifyAllExpectations();
		}
        public void EstablishSessionReturnsExistingSessionOnNextCall()
        {
            var shardedSessionImplementor = Stub <IShardedSessionImplementor>();
            var shard = new ShardImpl(
                shardedSessionImplementor,
                new ShardMetadataImpl(new ShardId(1), Stub <ISessionFactoryImplementor>()));

            shardedSessionImplementor.Expect(x => x.EstablishFor(shard)).Return(Stub <ISession>());

            var session  = shard.EstablishSession();
            var session2 = shard.EstablishSession();

            Assert.That(session2, Is.SameAs(session), "Next establish returns existing session");

            shardedSessionImplementor.VerifyAllExpectations();
        }
Beispiel #9
0
        public void TestAddOpenSessionEvent()
        {
            ShardImpl shard = new ShardImpl(new ShardId(1), Stub<ISessionFactoryImplementor>());//new SessionFactoryDefaultMock()
              try
              {
                  shard.AddOpenSessionEvent(null);
                  Assert.Fail("expected nre");
              }
              catch (NullReferenceException nre)
              {
                  // good
              }
              IOpenSessionEvent ose = Stub<IOpenSessionEvent>();//new OpenSessionEventDefaultMock()
              shard.AddOpenSessionEvent(ose);
              Assert.IsNotNull(shard.GetOpenSessionEvents());
              Assert.AreEqual(1, shard.GetOpenSessionEvents().Count);//.size()
              //Assert.AreSame(ose, shard.GetOpenSessionEvents().Find(0));//.get(0)

              // now add another and make sure it is added to the end
              IOpenSessionEvent anotherOse = Stub<IOpenSessionEvent>();
              shard.AddOpenSessionEvent(anotherOse);
              Assert.IsNotNull(shard.GetOpenSessionEvents());
              Assert.AreEqual(2, shard.GetOpenSessionEvents().Count);//.size()
              //Assert.AreSame(ose, shard.GetOpenSessionEvents().get(0));
              //Assert.AreSame(anotherOse, shard.GetOpenSessionEvents().get(1));
        }
Beispiel #10
0
        public void TestAddQueryEvent()
        {
            ShardImpl shard = new ShardImpl(new ShardId(1), Stub<ISessionFactoryImplementor>());
            try {
              shard.AddQueryEvent(null, null);
              Assert.Fail("expected npe");
            } catch (NullReferenceException npe) {
              // good
            }

            QueryId queryId = new QueryId(1);
            try {
              shard.AddQueryEvent(queryId, null);
              Assert.Fail("expected npe");
            } catch (NullReferenceException npe) {
              // good
            }

            IQueryEvent qe = Stub<IQueryEvent>();
            try {
              shard.AddQueryEvent(null, qe);
              Assert.Fail("expected npe");
            } catch (NullReferenceException npe) {
              // good
            }

            shard.AddQueryEvent(queryId, qe);
            //assertNotNull(shard.getQueryEventMap());
            //assertEquals(1, shard.getQueryEventMap().size());
            //assertEquals(1, shard.getQueryEventMap().get(queryId).size());
            //assertSame(qe, shard.getQueryEventMap().get(queryId).get(0));

            // now add another event to the same query
            IQueryEvent anotherQe = Stub<IQueryEvent>();
            shard.AddQueryEvent(queryId, anotherQe);
            //assertNotNull(shard.getQueryEventMap());
            //assertEquals(1, shard.getQueryEventMap().size());
            //assertEquals(2, shard.getQueryEventMap().get(queryId).size());
            //assertSame(qe, shard.getQueryEventMap().get(queryId).get(0));
            //assertSame(anotherQe, shard.getQueryEventMap().get(queryId).get(1));

            // now add an event to a different query
            QueryId anotherQueryId = new QueryId(3);
            IQueryEvent yetAnotherQe = Stub<IQueryEvent>();
            shard.AddQueryEvent(anotherQueryId, yetAnotherQe);
            //assertNotNull(shard.getQueryEventMap());
            //assertEquals(2, shard.getQueryEventMap().size());
            //assertEquals(2, shard.getQueryEventMap().get(queryId).size());
            //assertSame(qe, shard.getQueryEventMap().get(queryId).get(0));
            //assertSame(anotherQe, shard.getQueryEventMap().get(queryId).get(1));
            //assertEquals(1, shard.getQueryEventMap().get(anotherQueryId).size());
            //assertSame(yetAnotherQe, shard.getQueryEventMap().get(anotherQueryId).get(0));
        }
Beispiel #11
0
        public void TestAddCriteriaEvent()
        {
            ShardImpl shard = new ShardImpl(new ShardId(1), Stub<ISessionFactoryImplementor>());//new SessionFactoryDefaultMock()
            try
            {
                shard.AddCriteriaEvent(null, null);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            CriteriaId criteriaId = new CriteriaId(2);
            try
            {
                shard.AddCriteriaEvent(criteriaId, null);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            ICriteriaEvent ce = Stub<ICriteriaEvent>();//new CriteriaEventDefaultMock()
            try
            {
                shard.AddCriteriaEvent(null, ce);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            shard.AddCriteriaEvent(criteriaId, ce);
            //Assert.IsNotNull(shard.GetCriteriaEventMap());
            //Assert.Equals(1, shard.getCriteriaEventMap().size());
            //Assert.Equals(1, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));

            // now add another event to the same criteria
            ICriteriaEvent anotherCe = Stub<ICriteriaEvent>();
            //shard.AddCriteriaEvent(criteriaId, anotherCe);
            //Assert.IsNotNull(shard.getCriteriaEventMap());
            //Assert.Equals(1, shard.getCriteriaEventMap().size());
            //Assert.Equals(2, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));
            //Assert.AreSame(anotherCe, shard.getCriteriaEventMap().get(criteriaId).get(1));

            // now add an event to a different criteria
            CriteriaId anotherCriteriaId = new CriteriaId(3);
            ICriteriaEvent yetAnotherCe = Stub<ICriteriaEvent>();
            shard.AddCriteriaEvent(anotherCriteriaId, yetAnotherCe);
            //Assert.IsNotNull(shard.getCriteriaEventMap());
            //Assert.Equals(2, shard.getCriteriaEventMap().size());
            //Assert.Equals(2, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));
            //Assert.AreSame(anotherCe, shard.getCriteriaEventMap().get(criteriaId).get(1));
            //Assert.Equals(1, shard.getCriteriaEventMap().get(anotherCriteriaId).size());
            //Assert.AreSame(yetAnotherCe, shard.getCriteriaEventMap().get(anotherCriteriaId).get(0));
        }
Beispiel #12
0
        public void TestAddCriteriaEvent()
        {
            ShardImpl shard = new ShardImpl(new ShardId(1), Stub <ISessionFactoryImplementor>());//new SessionFactoryDefaultMock()

            try
            {
                shard.AddCriteriaEvent(null, null);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            CriteriaId criteriaId = new CriteriaId(2);

            try
            {
                shard.AddCriteriaEvent(criteriaId, null);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            ICriteriaEvent ce = Stub <ICriteriaEvent>();//new CriteriaEventDefaultMock()

            try
            {
                shard.AddCriteriaEvent(null, ce);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            shard.AddCriteriaEvent(criteriaId, ce);
            //Assert.IsNotNull(shard.GetCriteriaEventMap());
            //Assert.Equals(1, shard.getCriteriaEventMap().size());
            //Assert.Equals(1, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));

            // now add another event to the same criteria
            ICriteriaEvent anotherCe = Stub <ICriteriaEvent>();
            //shard.AddCriteriaEvent(criteriaId, anotherCe);
            //Assert.IsNotNull(shard.getCriteriaEventMap());
            //Assert.Equals(1, shard.getCriteriaEventMap().size());
            //Assert.Equals(2, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));
            //Assert.AreSame(anotherCe, shard.getCriteriaEventMap().get(criteriaId).get(1));

            // now add an event to a different criteria
            CriteriaId     anotherCriteriaId = new CriteriaId(3);
            ICriteriaEvent yetAnotherCe      = Stub <ICriteriaEvent>();

            shard.AddCriteriaEvent(anotherCriteriaId, yetAnotherCe);
            //Assert.IsNotNull(shard.getCriteriaEventMap());
            //Assert.Equals(2, shard.getCriteriaEventMap().size());
            //Assert.Equals(2, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));
            //Assert.AreSame(anotherCe, shard.getCriteriaEventMap().get(criteriaId).get(1));
            //Assert.Equals(1, shard.getCriteriaEventMap().get(anotherCriteriaId).size());
            //Assert.AreSame(yetAnotherCe, shard.getCriteriaEventMap().get(anotherCriteriaId).get(0));
        }