Esempio n. 1
0
        public void GetRankingData_RankingsFound_ReturnRankingList()
        {
            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.IRankingManager), binding, address.Uri);

                var smb = new ServiceMetadataBehavior {
                    HttpGetEnabled = false
                };
                serviceHost.Description.Behaviors.Add(smb);
                InstanceContext instanceContext = new InstanceContext(new RankingCallbackHandler());
                rankingClient = new RankingManagerClient(instanceContext);
                endpoint.Name = rankingClient.Endpoint.Name;

                serviceHost.Open();
                rankingClient.GetRankingData();
                RankingCallbackHandler rankHandler = new RankingCallbackHandler();
                List <Ranking>         result      = rankHandler.rankings;

                Assert.IsTrue(result.Count > 0);
            }
            catch (EndpointNotFoundException)
            {
                rankingClient.Abort();
            }
            catch (CommunicationException)
            {
                rankingClient.Abort();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Crea una solicitud para consultar las puntuaciones de <c>Ranking</c> en el ranking global del sistema
 /// </summary>
 /// <exception>
 /// Esta excepcion puede retornar una excepcion tipo EndpointNotFoundException
 /// </exception>
 public static void AddRankingPetitionCallback()
 {
     try
     {
         server.GetRankingData();
     }
     catch (EndpointNotFoundException)
     {
         MessageBox.Show(Resources.NoConnectionMessage);
     }
 }