Exemplo n.º 1
0
        public void Setup()
        {
            PacketFactory.Initialize <NoS0575Packet>();
            var builder = new ConfigurationBuilder();
            var databaseConfiguration = new SqlConnectionConfiguration();

            builder.SetBasePath(Directory.GetCurrentDirectory() + ConfigurationPath);
            builder.AddJsonFile("database.json", false);
            builder.Build().Bind(databaseConfiguration);
            databaseConfiguration.Database = "postgresunittest";
            var sqlconnect = databaseConfiguration;

            DataAccessHelper.Instance.EnsureDeleted(sqlconnect);
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo(ConfigurationPath + "/log4net.config"));
            Logger.InitializeLogger(LogManager.GetLogger(typeof(LoginPacketController)));
            DataAccessHelper.Instance.Initialize(sqlconnect);
            DAOFactory.RegisterMapping(typeof(GameObject.Character).Assembly);
            var map = new MapDTO {
                MapId = 1
            };

            DAOFactory.MapDAO.InsertOrUpdate(ref map);
            _acc = new AccountDTO {
                Name = Name, Password = EncryptionHelper.Sha512("test")
            };
            DAOFactory.AccountDAO.InsertOrUpdate(ref _acc);
            _session.InitializeAccount(_acc);
            _handler = new LoginPacketController(new LoginConfiguration());
            _handler.RegisterSession(_session);
            WebApiAccess.RegisterBaseAdress();
            WebApiAccess.Instance.MockValues = new Dictionary <string, object>();
        }
Exemplo n.º 2
0
        public void Setup()
        {
            PacketFactory.Initialize <NoS0575Packet>();
            var builder        = new ConfigurationBuilder();
            var contextBuilder = new DbContextOptionsBuilder <NosCoreContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString());

            DataAccessHelper.Instance.InitializeForTest(contextBuilder.Options);
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo(ConfigurationPath + "/log4net.config"));
            Logger.InitializeLogger(LogManager.GetLogger(typeof(LoginPacketController)));
            var map = new MapDTO {
                MapId = 1
            };

            DAOFactory.MapDAO.InsertOrUpdate(ref map);
            _acc = new AccountDTO {
                Name = Name, Password = EncryptionHelper.Sha512("test")
            };
            DAOFactory.AccountDAO.InsertOrUpdate(ref _acc);
            _session.InitializeAccount(_acc);
            _handler = new LoginPacketController(new LoginConfiguration());
            _handler.RegisterSession(_session);
            WebApiAccess.RegisterBaseAdress();
            WebApiAccess.Instance.MockValues = new Dictionary <string, object>();
        }
Exemplo n.º 3
0
 public void LoginOldClient()
 {
     _handler = new LoginPacketController(new LoginConfiguration
     {
         ClientData = "123456"
     });
     _handler.RegisterSession(_session);
     _handler.VerifyLogin(new NoS0575Packet
     {
         Password = EncryptionHelper.Sha512("test"),
         Name     = Name.ToUpper()
     });
     Assert.IsTrue(_session.LastPacket is FailcPacket);
     Assert.IsTrue(((FailcPacket)_session.LastPacket).Type == LoginFailType.OldClient);
 }
Exemplo n.º 4
0
        public void Setup()
        {
            PacketFactory.Initialize <NoS0575Packet>();
            var contextBuilder =
                new DbContextOptionsBuilder <NosCoreContext>().UseInMemoryDatabase(
                    databaseName: Guid.NewGuid().ToString());

            DataAccessHelper.Instance.InitializeForTest(contextBuilder.Options);
            var map = new MapDto {
                MapId = 1
            };

            DaoFactory.MapDao.InsertOrUpdate(ref map);
            _acc = new AccountDto {
                Name = Name, Password = EncryptionHelper.Sha512("test")
            };
            DaoFactory.AccountDao.InsertOrUpdate(ref _acc);
            _session.InitializeAccount(_acc);
            _handler = new LoginPacketController(new LoginConfiguration());
            _handler.RegisterSession(_session);
            WebApiAccess.RegisterBaseAdress();
            WebApiAccess.Instance.MockValues = new Dictionary <string, object>();
        }