Пример #1
0
        public void ItChecksParentFacet()
        {
            var e = Assert.Catch <FacetSearchException>(() => {
                ClientApp.Resolve <FacetCaller>().CallFacetMethod(
                    typeof(WrongFacet),
                    nameof(SomeFacet.MyProcedure)
                    ).Done();
            });

            StringAssert.Contains("Facet 'WrongFacet' was not found.", e.Message);
        }
        /// <summary>
        /// Make the given player the authenticated player
        /// </summary>
        protected BackendTestCase ActingAs(Entity player)
        {
            var manager = App.Resolve <AuthenticationManager>();

            manager.SetPlayer(player);

            // HACK TO STORE THE UPDATED SESSION:
            // I need to figure out how to properly merge test facade access
            // with middleware logic so that it does not interfere.
            var sessionRepo = ClientApp.Resolve <ClientSessionIdRepository>();

            if (sessionRepo.GetSessionId() == null)
            {
                sessionRepo.StoreSessionId(Str.Random(16));
            }
            Session.Set(AuthenticationManager.SessionKey, player?.EntityId);
            App.Resolve <ISession>().StoreSession(sessionRepo.GetSessionId());

            return(this);
        }
        public void ItLoadsAuthenticatedPlayer()
        {
            var player = new PlayerEntity {
                name = "John"
            };

            player.Save();
            GenerateSessionId();

            Session.Set(AuthenticationManager.SessionKey, player.EntityId);

            // HACK TO STORE THE UPDATED SESSION:
            // I need to figure out how to properly merge test facade access
            // with middleware logic so that it does not interfere.
            App.Resolve <ISession>().StoreSession(
                ClientApp.Resolve <ClientSessionIdRepository>().GetSessionId()
                );

            var returned = OnFacet <AuthenticationFacet> .CallSync <PlayerEntity>(
                nameof(AuthenticationFacet.GetPlayer)
                );

            Assert.AreEqual("John", returned?.name);
        }
 /// <summary>
 /// Generates a session ID and stores it in the client application
 /// </summary>
 protected void GenerateSessionId()
 {
     ClientApp.Resolve <ClientSessionIdRepository>().StoreSessionId(
         ServerSessionIdRepository.GenerateSessionId()
         );
 }