Exemple #1
0
        public void GetMailResult_ReturnSendError_MailResult()
        {
            try
            {
                var baseAddress = new Uri("net.tcp://*****:*****@gmail.com",
                    PinConfirmacion       = "1234",
                    PreguntaRecuperacion  = "testquestion?",
                    RespuestaConfirmacion = "testanswer",
                    IdCreador             = 1,
                    IdLenguaje            = 1,
                    Status                = "No Verificado"
                };

                playerClient.SendMail(testPlayer);
                PlayerCallbackHandler playerHandler = new PlayerCallbackHandler();
                MailResult            result        = playerHandler.mailResult;

                Assert.AreEqual(result, MailResult.SendError);
            }
            catch (EndpointNotFoundException)
            {
                playerClient.Abort();
            }
            catch (CommunicationException)
            {
                playerClient.Abort();
            }
        }
Exemple #2
0
        public void SendActualPlayer_ReturnErrorObtainingData_DataObtainedResult()
        {
            try
            {
                var baseAddress = new Uri("net.tcp://localhost:8090/Contratos");
                serviceHost = new ServiceHost(typeof(Contratos.MainService), baseAddress);
                System.ServiceModel.Channels.Binding binding = new NetTcpBinding();
                var address  = new EndpointAddress("net.tcp://localhost:8090/ServerTests");
                var endpoint = serviceHost
                               .AddServiceEndpoint(typeof(Contratos.IPlayerManager), binding, address.Uri);

                var smb = new ServiceMetadataBehavior {
                    HttpGetEnabled = false
                };
                serviceHost.Description.Behaviors.Add(smb);
                InstanceContext instanceContext = new InstanceContext(new PlayerCallbackHandler());
                playerClient  = new PlayerManagerClient(instanceContext);
                endpoint.Name = playerClient.Endpoint.Name;

                serviceHost.Open();
                serviceHost.Close();

                Jugador testPlayer = new Jugador
                {
                    Apodo       = "savetestplayer",
                    Contrasenia = "password123",
                };

                playerClient.GetActualPlayer(testPlayer);
                PlayerCallbackHandler playerHandler = new PlayerCallbackHandler();
                DataObtainedResult    result        = playerHandler.dataObtainedResult;

                Assert.AreEqual(result, DataObtainedResult.ErrorObtainingData);
            }
            catch (EndpointNotFoundException)
            {
                playerClient.Abort();
            }
            catch (CommunicationException)
            {
                playerClient.Abort();
            }
        }
Exemple #3
0
        public void GetLoginResult_ReturnLOGGEDPLAYER_LoginResult()
        {
            try
            {
                var baseAddress = new Uri("net.tcp://localhost:8090/Contratos");
                serviceHost = new ServiceHost(typeof(Contratos.MainService), baseAddress);
                System.ServiceModel.Channels.Binding binding = new NetTcpBinding();
                var address  = new EndpointAddress("net.tcp://localhost:8090/ServerTests");
                var endpoint = serviceHost
                               .AddServiceEndpoint(typeof(Contratos.IPlayerManager), binding, address.Uri);

                var smb = new ServiceMetadataBehavior {
                    HttpGetEnabled = false
                };
                serviceHost.Description.Behaviors.Add(smb);
                InstanceContext instanceContext = new InstanceContext(new PlayerCallbackHandler());
                playerClient  = new PlayerManagerClient(instanceContext);
                endpoint.Name = playerClient.Endpoint.Name;

                serviceHost.Open();

                Jugador testPlayer = new Jugador
                {
                    Apodo       = "pklove3456",
                    Contrasenia = "bobcholo1"
                };

                playerClient.Login(testPlayer);
                playerClient.Login(testPlayer);
                PlayerCallbackHandler playerHandler = new PlayerCallbackHandler();
                LoginResult           result        = playerHandler.loginResult;

                Assert.AreEqual(result, LoginResult.LOGGED_PLAYER);
            }
            catch (EndpointNotFoundException)
            {
                playerClient.Abort();
            }
            catch (CommunicationException)
            {
                playerClient.Abort();
            }
        }