Inheritance: MarshalByRefObject, ISession
        public string GetSessionId()
        {
            SessionImpl sessionImpl = (SessionImpl)_sessionFactory.GetCurrentSession();
            var         ide         = sessionImpl.SessionId;

            return(ide.ToString());
        }
        public void MapsToEnum()
        {
            using (ISession s = OpenSession())
            {
                A                a         = new A();
                SessionImpl      impl      = (SessionImpl)s;
                IEntityPersister persister = impl.GetEntityPersister(typeof(A).FullName, a);

                int index = -1;
                for (int i = 0; i < persister.PropertyNames.Length; i++)
                {
                    if (persister.PropertyNames[i] == "NullableValue")
                    {
                        index = i;
                        break;
                    }
                }

                if (index == -1)
                {
                    Assert.Fail("Property NullableValue not found.");
                }

                Assert.That(persister.PropertyTypes[index], Is.AssignableTo <PersistentEnumType>());
            }
        }
        public void GetPost_CreatesChatPostCorrectly()
        {
            var baseUri = new Uri("http://localhost");
            var thread  = new Thread
            {
                Order = new[] { POST_ID, ROOT_ID },
                Posts = new Dictionary <string, Post>()
            };

            thread.Posts[POST_ID] = new Post {
                Id = POST_ID, RootId = ROOT_ID
            };
            thread.Posts[ROOT_ID] = new Post {
                Id = ROOT_ID, RootId = string.Empty
            };
            var restService    = new Mock <IRestService>();
            var chatPost       = new Mock <IChatPost>();
            var channelFactory = new Mock <IChatPostFactory>();

            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, TEAM_GUID, thread.Posts[POST_ID]))
            .Returns(chatPost.Object);
            restService.Setup(x => x.GetPostById(baseUri, TOKEN, TEAM_GUID, POST_ID)).Returns(thread);
            var sut = new SessionImpl(restService.Object, baseUri,
                                      TOKEN, USER_ID, TEAM_GUID, Mock.Of <IChatChannelFactory>(), channelFactory.Object);

            var result = sut.GetPost(POST_ID);

            Assert.That(result, Is.EqualTo(chatPost.Object));
        }
Example #4
0
File: server.cs Project: mono/gert
	public ISession LogOn (string user)
	{
		ISession session = new SessionImpl ();
		SessionContext ctx = new SessionContext (session);
		CallContext.SetData ("session_ctx", ctx);
		return session;
	}
Example #5
0
        public void SessionImpl_Disposes_Connection_On_Dispose()
        {
            var fixture = new PersistenceAdapterFixture();
            var session = new SessionImpl(fixture.Connection);

            session.Dispose();

            fixture.ConnectionMock.Verify(c => c.Dispose());
        }
Example #6
0
        public void SessionImpl_Raises_OperationInvalidException_If_Connection_Has_Already_Been_Opened_On_Open()
        {
            var fixture = new PersistenceAdapterFixture();

            fixture.ConnectionMock.Setup(c => c.State).Returns(ConnectionState.Open);

            using (var session = new SessionImpl(fixture.Connection))
                AssertRaise <InvalidOperationException>(() => { session.Open(); });
        }
Example #7
0
        public void SessionImpl_Raises_InvalidOperationException_If_Connection_Is_Closed_On_Close()
        {
            var fixture = new PersistenceAdapterFixture();

            fixture.ConnectionMock.Setup(c => c.State).Returns(ConnectionState.Closed);

            using (var session = new SessionImpl(fixture.Connection))
                AssertRaise <InvalidOperationException>(() => { session.Close(); });
        }
Example #8
0
        public void SessionImpl_Can_Be_Closed()
        {
            var fixture = new PersistenceAdapterFixture();

            fixture.ConnectionMock.Setup(c => c.State).Returns(ConnectionState.Open);

            using (var session = new SessionImpl(fixture.Connection))
                session.Close();

            fixture.ConnectionMock.Verify(c => c.Close());
        }
Example #9
0
        public void SessionValues_CanBeRead()
        {
            var checks  = new Dictionary <string, byte[]>();
            var session = CreateSessionMock(checks);

            var oscriptSession = new SessionImpl(session);

            oscriptSession.SetString("user", "EvilBeaver");
            oscriptSession.SetNumber("num", 1);

            Assert.Equal("EvilBeaver", oscriptSession.GetString("user").AsString());
            Assert.Equal(1m, oscriptSession.GetNumber("num").AsNumber());
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            var Session = new SessionImpl("http://*****:*****@liferay.com", "test"));

            Push.With(Session)
            .WithPortalVersion(70)
            .OnSuccess(this)
            .OnFailure(this)
            .Register(this, "393909434085");
        }
Example #11
0
 private static IUnityAnalyticsSession GetSingleton()
 {
     if (s_Implementation == null)
     {
         Logger.loggerInstance = new UnityLogger();
         IPlatformWrapper  platformWrapper  = PlatformWrapper.platform;
         IFileSystem       fileSystem       = new FileSystem();
         ICoroutineManager coroutineManager = new UnityCoroutineManager();
         s_Implementation = new SessionImpl(platformWrapper, coroutineManager, fileSystem);
         GameObserver.CreateComponent(platformWrapper, s_Implementation);
     }
     return(s_Implementation);
 }
Example #12
0
        public void SessionValues_CanBeSet()
        {
            lock (TestOrderingLock.Lock)
            {
                var wa = new WebApplicationEngine();

                var checks  = new Dictionary <string, byte[]>();
                var session = CreateSessionMock(checks);

                var oscriptSession = new SessionImpl(session);
                oscriptSession.SetString("user", "EvilBeaver");

                Assert.Equal("EvilBeaver", Encoding.Default.GetString(checks["user"]));
            }
        }
Example #13
0
        public long GetNextId()
        {
            var         idGen   = ((SessionFactoryImpl)SessionFactory).GetIdentifierGenerator(RootEntityName);
            SessionImpl session = (SessionImpl)SessionFactory.OpenSession();

            try
            {
                //System.out.println("================ Table Id Generator =================");
                var id = idGen.Generate(session, null);
                return(Convert.ToInt64(id));
            }
            finally
            {
                session.Close();
            }
        }
Example #14
0
        public void SessionValues_CanGetKeys()
        {
            lock (TestOrderingLock.Lock)
            {
                var wa = new WebApplicationEngine();

                var checks  = new Dictionary <string, byte[]>();
                var session = CreateSessionMock(checks);

                var oscriptSession = new SessionImpl(session);
                oscriptSession.SetString("user", "EvilBeaver");
                oscriptSession.SetString("password", "1");

                var arr = oscriptSession.GetKeys();
                Assert.Equal(2, arr.Count());
                Assert.NotEqual(arr.Find(ValueFactory.Create("user")), ValueFactory.Create());
                Assert.NotEqual(arr.Find(ValueFactory.Create("password")), ValueFactory.Create());
            }
        }
Example #15
0
 private static IUnityAnalyticsSession GetSingleton()
 {
     if (s_Implementation == null)
     {
         Logger.loggerInstance = new UnityLogger();
         IPlatformWrapper platformWrapper = PlatformWrapper.platform;
                         #if NETFX_CORE
         IFileSystem fileSystem = new WindowsFileSystem();
                         #elif UNITY_WEBPLAYER || UNITY_WEBGL
         IFileSystem fileSystem = new VirtualFileSystem();
                         #else
         IFileSystem fileSystem = new FileSystem();
                         #endif
         ICoroutineManager coroutineManager = new UnityCoroutineManager();
         s_Implementation = new SessionImpl(platformWrapper, coroutineManager, fileSystem);
         GameObserver.CreateComponent(platformWrapper, s_Implementation);
     }
     return(s_Implementation);
 }
        public void GetChannel_GetsChannelsFromRestAndCreateChannelObjects()
        {
            var baseUri = new Uri("http://localhost/");
            var channel = new Channel
            {
                ChannelId = CHANNEL1_ID
            };
            var channelObj     = new Mock <IChatChannel>();
            var restService    = Mock.Of <IRestService>();
            var channelFactory = new Mock <IChatChannelFactory>();

            channelFactory.Setup(
                x => x.NewInstance(restService, baseUri, TOKEN, USER_ID, TEAM_GUID, channel))
            .Returns(channelObj.Object);
            var sut = new SessionImpl(restService, baseUri,
                                      TOKEN, USER_ID, TEAM_GUID, channelFactory.Object, Mock.Of <IChatPostFactory>());

            var result = sut.GetChannel(CHANNEL1_ID);

            Assert.That(result, Is.EqualTo(channelObj.Object));
        }
Example #17
0
        public void GetChannel_GetsChannelsFromRestAndCreateChannelObjects()
        {
            var baseUri = new Uri("http://localhost/");
            var channel = new Channel
            {
                Id = CHANNEL_ID,
            };
            var channelObj     = new Mock <IChatChannel>();
            var restService    = Mock.Of <IRestService>();
            var channelFactory = new Mock <IChatChannelFactory>();

            channelFactory.Setup(
                x => x.NewInstance(restService, baseUri, TOKEN, TEAM_ID, channel))
            .Returns(channelObj.Object);
            var sut = new SessionImpl(restService, baseUri,
                                      TOKEN, TEAM_ID, channelFactory.Object, Mock.Of <IChatPostFactory>());

            var result = sut.GetChannel(CHANNEL_ID);

            result.ShouldBeEquivalentTo(channelObj.Object);
        }
        public void GetChannels_GetsChannelsFromRestAndCreateChannelObjects()
        {
            var baseUri     = new Uri("http://localhost/");
            var channelList = new ChannelList
            {
                Channels = new List <Channel>
                {
                    new Channel
                    {
                        ChannelId   = CHANNEL1_ID,
                        ChannelName = CHANNEL1_NAME
                    },
                    new Channel
                    {
                        ChannelId   = CHANNEL2_ID,
                        ChannelName = CHANNEL2_NAME
                    }
                }
            };
            var list = new List <IChatChannel> {
                Mock.Of <IChatChannel>(), Mock.Of <IChatChannel>()
            };
            var restService = new Mock <IRestService>();

            restService.Setup(x => x.GetChannelList(baseUri, TOKEN, TEAM_GUID)).Returns(channelList);
            var channelFactory = new Mock <IChatChannelFactory>();

            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, USER_ID, TEAM_GUID, channelList.Channels[0]))
            .Returns(list[0]);
            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, USER_ID, TEAM_GUID, channelList.Channels[1]))
            .Returns(list[1]);
            var sut = new SessionImpl(restService.Object, baseUri,
                                      TOKEN, USER_ID, TEAM_GUID, channelFactory.Object, Mock.Of <IChatPostFactory>());

            var result = sut.GetChannels();

            Assert.True(result.SequenceEqual(list));
        }
Example #19
0
        public void GetPost_CreatesChatPostCorrectly()
        {
            var baseUri = new Uri("http://localhost");

            var post = new Post {
                Id = POST_ID, RootId = ROOT_ID
            };
            var restService    = new Mock <IRestService>();
            var chatPost       = new Mock <IChatPost>();
            var channelFactory = new Mock <IChatPostFactory>();

            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, TEAM_ID, post))
            .Returns(chatPost.Object);
            restService.Setup(x => x.GetPostById(baseUri, TOKEN, POST_ID)).Returns(post);
            var sut = new SessionImpl(restService.Object, baseUri,
                                      TOKEN, TEAM_ID, Mock.Of <IChatChannelFactory>(), channelFactory.Object);

            var result = sut.GetPost(POST_ID);

            result.ShouldBeEquivalentTo(chatPost.Object);
        }
Example #20
0
        public void GetChannels_GetsChannelsFromRestAndCreateChannelObjects()
        {
            var baseUri     = new Uri("http://localhost/");
            var channelList = new List <Channel>
            {
                new Channel
                {
                    Id   = CHANNEL_ID,
                    Name = CHANNEL_NAME
                },
                new Channel
                {
                    Id   = CHANNEL_ID_2,
                    Name = CHANNEL_NAME_2
                }
            };
            var list = new List <IChatChannel> {
                Mock.Of <IChatChannel>(), Mock.Of <IChatChannel>()
            };
            var restService = new Mock <IRestService>();

            restService.Setup(x => x.GetChannels(baseUri, TOKEN, TEAM_ID)).Returns(channelList);
            var channelFactory = new Mock <IChatChannelFactory>();

            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, TEAM_ID, channelList[0]))
            .Returns(list[0]);
            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, TEAM_ID, channelList[1]))
            .Returns(list[1]);
            var sut = new SessionImpl(restService.Object, baseUri,
                                      TOKEN, TEAM_ID, channelFactory.Object, Mock.Of <IChatPostFactory>());

            var result = sut.GetChannels();

            result.ShouldBeEquivalentTo(channelList);
        }
		private static IUnityAnalyticsSession GetSingleton()
		{
			if (s_Implementation == null) {
				Logger.loggerInstance = new UnityLogger();
				IPlatformWrapper platformWrapper = PlatformWrapper.platform;
				IFileSystem fileSystem = new FileSystem();
				ICoroutineManager coroutineManager = new UnityCoroutineManager();
				s_Implementation = new SessionImpl(platformWrapper, coroutineManager, fileSystem);
				GameObserver.CreateComponent(platformWrapper, s_Implementation);
			}
			return s_Implementation;
		}
Example #22
0
 /**
  * @brief Gets a IP address.<br>
  * This method returns a IP address when signed in successfully.
  *
  * @return IP address.
  */
 public string GetIPAddress()
 {
     Log.Debug("[Session] GetIPAddress");
     return(SessionImpl.GetIPAddress());
 }
Example #23
0
        private static void Main()
        {
            var performance = new AdoNetPerformance();
            var database = new DatabaseImpl(ConnectionString);

            Console.WriteLine("Process: " + performance.InstanceName);
            Console.WriteLine();
            Console.WriteLine("Press any key to start ADO.NET performance test...");
            Console.ReadLine();

            var sw = new Stopwatch();
            sw.Start();

            for (int i = 0; i < 500; i++)
            {
                var session = new SessionImpl(database);
                var formTexts = session.FindAll<FormText>();
                session.Dispose();
                Console.Write(".");
            }
            sw.Stop();

            Console.WriteLine();
            Console.WriteLine(sw.ElapsedMilliseconds + " ms");

            performance.DisplayPerformanceCounters();
        }
Example #24
0
        private static void MeasurePerformance()
        {
            var program = new Program();

            const int queries = 5000;
            const int runs = 10;

            for(int x = 0; x<runs; x++)
            {
                Console.WriteLine("Pass {0}", x + 1);

                program.Measure((int) MeasurementType.SingleSessionSingleTransaction, db =>
                {
                    using(ISession session = new SessionImpl(db))
                    {
                        using(ITransaction transaction = session.BeginTransaction())
                        {
                            for(int i = 0; i<queries; i++)
                            {
                                session.Get<FormText>(i);
                            }
                            transaction.Commit();
                        }
                    }
                });

                program.Measure((int) MeasurementType.SingleSessionMultipleTransactions, db =>
                {
                    using(ISession session = new SessionImpl(db))
                    {
                        for(int i = 0; i<queries; i++)
                        {
                            using(ITransaction transaction = session.BeginTransaction())
                            {
                                session.Get<FormText>(i);
                                transaction.Commit();
                            }
                        }
                    }
                });

                program.Measure((int) MeasurementType.MultipleSessionsMultipleTransactions, db =>
                {
                    for(int i = 0; i<queries; i++)
                    {
                        using(ISession session = new SessionImpl(db))
                        {
                            using(ITransaction transaction = session.BeginTransaction())
                            {
                                session.Get<FormText>(i);
                                transaction.Commit();
                            }
                        }
                    }
                });

                program.Measure((int) MeasurementType.MultipleSessionsNoTransactions, db =>
                {
                    for(int i = 0; i<queries; i++)
                    {
                        using(ISession session = new SessionImpl(db))
                        {
                            session.Get<FormText>(i);
                        }
                    }
                });
                Console.WriteLine();
            }

            Console.WriteLine();
            program.DisplayStats();
        }
Example #25
0
 /**
  * @brief Gets a cipher data.<br>
  * This method returns a cipher data when signed in successfully.
  *
  * @return Cipher data.
  * @see Cipher
  */
 public Cipher GetCipherData(CipherType cipherType)
 {
     Log.Debug("[Session] GetCipherData cipherType:" + cipherType);
     return(SessionImpl.GetCipherData(cipherType));
 }
Example #26
0
 /**
  * @brief Gets a game token.
  *
  * This method returns a game token when signed in successfully.
  *
  * @return Game token.
  */
 public string GetGameToken()
 {
     Log.Debug("[Session] GetGameToken");
     return(SessionImpl.GetGameToken());
 }
Example #27
0
		private static IUnityAnalyticsSession GetSingleton()
		{
			if (s_Implementation == null) {
				Logger.loggerInstance = new UnityLogger();
				IPlatformWrapper platformWrapper = PlatformWrapper.platform;
				#if NETFX_CORE
				IFileSystem fileSystem = new WindowsFileSystem();
				#elif UNITY_WEBPLAYER || UNITY_WEBGL
				IFileSystem fileSystem = new VirtualFileSystem();
				#else
				IFileSystem fileSystem = new FileSystem();
				#endif
				ICoroutineManager coroutineManager = new UnityCoroutineManager();
				s_Implementation = new SessionImpl(platformWrapper, coroutineManager, fileSystem);
				GameObserver.CreateComponent(platformWrapper, s_Implementation);
			}
			return s_Implementation;
		}
Example #28
0
 /**
  * @brief Gets a channelId.<br>
  * This method returns a channelId when this player connected to this channel.
  *
  * @param channel Channel.
  * @see Channel
  * @return ChannelId.
  */
 public string GetChannelID(int channelCode)
 {
     Log.Debug("[Session] GetChannelID. channel:" + channelCode);
     return(SessionImpl.GetChannelId(channelCode));
 }
Example #29
0
 /**
  * @brief Gets a joined countryCode.<br>
  * This method returns a joined country code when signed in successfully.
  *
  * @return Joined country code.
  */
 public string GetJoinedCountryCode()
 {
     Log.Debug("[Session] GetJoinedCountryCode");
     return(SessionImpl.GetJoinedCountryCode());
 }
Example #30
0
 public CriteriaEx(Type type, SessionImpl session, int code)
     : base(type, session)
 {
     Session     = session;
     SessionCode = code;
 }
Example #31
0
 /**
  * @brief 현재 WorldId를 저장합니다.
  * @param worldId worldId.
  */
 public void SetWorld(string worldId)
 {
     Log.Debug("[Session] SetWorld worldId:" + worldId);
     SessionImpl.SetWorld(worldId);
 }
Example #32
0
 /**
  * @brief 현재 WorldId를 가져옵니다.
  * @return worldId.
  */
 public string GetWorld()
 {
     Log.Debug("[Session] GetWorld");
     return(SessionImpl.GetWorld());
 }
Example #33
0
 private Session()
 {
     SessionImpl.CreateSession();
 }
Example #34
0
 /**
  * @brief SignIn 응답이 성공 한 이후에 호출 할 수 있습니다.<br>
  * 인증 서버로 부터 응답 받은 값이며, 현재 PlayerID에 연결된 채널 정보를 알 수 있습니다.
  * @since 4.1.0
  */
 public string GetConnectedChannelsByAuthServer()
 {
     Log.Debug("[Session] GetConnectedChannelsByAuthServer");
     return(SessionImpl.GetConnectedChannelsByAuthServer());
 }
Example #35
0
 /**
  * @brief 현재 WorldId를 삭제합니다
  */
 public void RemoveWorld()
 {
     Log.Debug("[Session] RemoveWorld");
     SessionImpl.RemoveWorld();
 }