Exemplo n.º 1
0
        public void GetAdminReportResult_ReportsFound_ReturnREPORT_EXISTSResult()
        {
            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.IBanManager), binding, address.Uri);

                var smb = new ServiceMetadataBehavior {
                    HttpGetEnabled = false
                };
                serviceHost.Description.Behaviors.Add(smb);
                InstanceContext instanceContext = new InstanceContext(new BanCallbackHandler());
                banClient     = new BanManagerClient(instanceContext);
                endpoint.Name = banClient.Endpoint.Name;

                serviceHost.Open();
                banClient.GetReportData();
                BanCallbackHandler banHandler = new BanCallbackHandler();
                AdminReportResult  result     = banHandler.adminReportResult;
                Assert.AreEqual(result, AdminReportResult.REPORT_EXISTS);
            }
            catch (EndpointNotFoundException)
            {
                banClient.Abort();
            }
            catch (CommunicationException)
            {
                banClient.Abort();
            }
        }