当前位置: 首页>>代码示例>>C#>>正文


C# TestClient类代码示例

本文整理汇总了C#中TestClient的典型用法代码示例。如果您正苦于以下问题:C# TestClient类的具体用法?C# TestClient怎么用?C# TestClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestClient类属于命名空间,在下文中一共展示了TestClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupInformClientOfNeighbourTriggersNeighbourClientCreate

        /// <summary>
        /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
        /// viewer to setup a connection with the destination region.
        /// </summary>
        /// <param name='tc'></param>
        /// <param name='neighbourTcs'>
        /// A list that will be populated with any TestClients set up in response to 
        /// being informed about a destination region.
        /// </param>
        public static void SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
            TestClient tc, List<TestClient> neighbourTcs)
        {
            // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the
            // event queue).

            tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) =>
            {
                uint x, y;
                Utils.LongToUInts(neighbourHandle, out x, out y);
                x /= Constants.RegionSize;
                y /= Constants.RegionSize;

                m_log.DebugFormat(
                    "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}", 
                    x, y, neighbourExternalEndPoint);

                AgentCircuitData newAgent = tc.RequestClientInfo();

                Scene neighbourScene;
                SceneManager.Instance.TryGetScene(x, y, out neighbourScene);

                TestClient neighbourTc = new TestClient(newAgent, neighbourScene);
                neighbourTcs.Add(neighbourTc);
                neighbourScene.AddNewAgent(neighbourTc, PresenceType.User);
            };
        }
开发者ID:Michelle-Argus,项目名称:opensim,代码行数:36,代码来源:EntityTransferHelpers.cs

示例2: FlyToCommand

 public FlyToCommand(TestClient Client)
 {
     Name = "FlyTo";
     Description = "Fly the avatar toward the specified position for a maximum of seconds. Usage: FlyTo x y z [seconds]";
     Category = CommandCategory.Movement;
     Client.Objects.TerseObjectUpdate += Objects_OnObjectUpdated;            
 }
开发者ID:Vinhold,项目名称:halcyon,代码行数:7,代码来源:FlyToCommand.cs

示例3: ValidHelloMessage

        public void ValidHelloMessage ()
        {
            var responseStream = new MemoryStream ();
            var stream = new TestStream (new MemoryStream (helloMessage), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock<IServer<byte,byte>> ();
            var byteServer = mockByteServer.Object;
            var byteClient = new TestClient (stream);

            var server = new RPCServer (byteServer);
            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow ();
            server.Start ();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs<byte,byte> (byteClient);
            mockByteServer.Raise (m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsTrue (eventArgs.Request.ShouldAllow);
            Assert.IsFalse (eventArgs.Request.ShouldDeny);

            server.Update ();
            Assert.AreEqual (1, server.Clients.Count ());
            Assert.AreEqual ("Jebediah Kerman!!!", server.Clients.First ().Name);

            byte[] bytes = responseStream.ToArray ();
            byte[] responseBytes = byteClient.Guid.ToByteArray ();
            Assert.IsTrue (responseBytes.SequenceEqual (bytes));
        }
开发者ID:paperclip,项目名称:krpc,代码行数:29,代码来源:RPCServerTest.cs

示例4: GoodDownload

        public void GoodDownload()
        {
            var res = new MockResponse()
            {
                ContentType = "text/plain",
                Code = System.Net.HttpStatusCode.OK,
                Body = "test,report"
            };

            using (var c = new TestClient(res))
            {
                var actualResult = c.Client.Export.Download(123);

                // test the request
                var queryString = c.Request.QueryString;
                GeneralClient.TestRequiredParameters(queryString);

                queryString.ContainsAndEquals("token", "123");

                Assert.IsFalse(actualResult.Pending);
                Assert.IsNotNull(actualResult.ExportStream);

                var actualReport = String.Empty;
                using (StreamReader reader = new StreamReader(actualResult.ExportStream, Encoding.UTF8))
                {
                    actualReport = reader.ReadToEnd();
                }

                Assert.AreEqual("test,report", actualReport);
            }
        }
开发者ID:ryanlsmith,项目名称:api-csharp,代码行数:31,代码来源:Download.cs

示例5: InPacketTest

        /// <summary>
        /// More a placeholder, really
        /// </summary>        
        public void InPacketTest()
        {
            TestHelper.InMethod();

            AgentCircuitData agent = new AgentCircuitData();
            agent.AgentID = UUID.Random();
            agent.firstname = "testfirstname";
            agent.lastname = "testlastname";
            agent.SessionID = UUID.Zero;
            agent.SecureSessionID = UUID.Zero;
            agent.circuitcode = 123;
            agent.BaseFolder = UUID.Zero;
            agent.InventoryFolder = UUID.Zero;
            agent.startpos = Vector3.Zero;
            agent.CapsPath = "http://wibble.com";
            
            TestLLUDPServer testLLUDPServer;
            TestLLPacketServer testLLPacketServer;
            AgentCircuitManager acm;
            IScene scene = new MockScene();
            SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);
            
            TestClient testClient = new TestClient(agent, scene);
            
            ILLPacketHandler packetHandler 
                = new LLPacketHandler(testClient, testLLPacketServer, new ClientStackUserSettings());
            
            packetHandler.InPacket(new AgentAnimationPacket());
            LLQueItem receivedPacket = packetHandler.PacketQueue.Dequeue();
            
            Assert.That(receivedPacket, Is.Not.Null);
            Assert.That(receivedPacket.Incoming, Is.True);
            Assert.That(receivedPacket.Packet, Is.TypeOf(typeof(AgentAnimationPacket)));
        }
开发者ID:ChrisD,项目名称:opensim,代码行数:37,代码来源:PacketHandlerTests.cs

示例6: Given

 protected override void Given()
 {
     var approvedEntitiesCache = new ApprovedEntitiesCache();
     var eventProcessorCache = PreProcessorHelper.CreateEventProcessorCache();
     _testClient1 = new DomainRepository(new AggregateRootFactory(eventProcessorCache, approvedEntitiesCache)).CreateNew<TestClient>();
     _testClient2 = new DomainRepository(new AggregateRootFactory(eventProcessorCache, approvedEntitiesCache)).CreateNew<TestClient>();
 }

示例7: BadRequest

        public void BadRequest()
        {
            var res = new MockResponse()
            {
                ContentType = "application/json",
                Code = System.Net.HttpStatusCode.NotFound,
                Body = @"{ ""message"": ""Invalid Format"" }"
            };

            using (var c = new TestClient(res))
            {
                try
                {
                    c.Client.Export.Request("test", SlideRoom.API.Resources.RequestFormat.Csv);
                    Assert.Fail("should throw an exception");
                }
                catch (SlideRoom.API.SlideRoomAPIException e)
                {
                    Assert.AreEqual("Invalid Format", e.Message);
                    Assert.AreEqual(System.Net.HttpStatusCode.NotFound, e.StatusCode);
                }
                catch
                {
                    Assert.Fail("should throw a SlideRoomAPIException");
                }
            }
        }
开发者ID:slideroom,项目名称:api-csharp,代码行数:27,代码来源:Request.cs

示例8: GoodRequest

        public void GoodRequest()
        {
            var res = new MockResponse()
            {
                ContentType = "application/json",
                Code = System.Net.HttpStatusCode.OK,
                Body = @"{ ""token"": 123, ""submissions"": 456, ""message"": ""test""}"
            };

            using (var c = new TestClient(res))
            {
                var actualResult = c.Client.Export.Request("test", SlideRoom.API.Resources.RequestFormat.Csv);

                // test the request
                var queryString = c.Request.QueryString;
                GeneralClient.TestRequiredParameters(queryString);

                queryString.ContainsAndEquals("export", "test");
                queryString.ContainsAndEquals("format", "csv");
                queryString.NotContains("ss");
                queryString.NotContains("since");

                var expectedResult = new SlideRoom.API.Resources.RequestResult()
                {
                    Message = "test",
                    Submissions = 456,
                    Token = 123
                };

                Assert.AreEqual(expectedResult.Message, actualResult.Message);
                Assert.AreEqual(expectedResult.Submissions, actualResult.Submissions);
                Assert.AreEqual(expectedResult.Token, actualResult.Token);
            }
        }
开发者ID:slideroom,项目名称:api-csharp,代码行数:34,代码来源:Request.cs

示例9: SetUpInformClientOfNeighbour

        /// <summary>
        /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
        /// viewer to setup a connection with the destination region.
        /// </summary>
        /// <param name='tc'></param>
        /// <param name='neighbourTcs'>
        /// A list that will be populated with any TestClients set up in response to 
        /// being informed about a destination region.
        /// </param>
        public static void SetUpInformClientOfNeighbour(TestClient tc, List<TestClient> neighbourTcs)
        {
            // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the
            // event queue).

            tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) =>
            {
                uint x, y;
                Utils.LongToUInts(neighbourHandle, out x, out y);
                x /= Constants.RegionSize;
                y /= Constants.RegionSize;

                m_log.DebugFormat(
                    "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}", 
                    x, y, neighbourExternalEndPoint);

                // In response to this message, we are going to make a teleport to the scene we've previous been told
                // about by test code (this needs to be improved).
                AgentCircuitData newAgent = tc.RequestClientInfo();

                Scene neighbourScene;
                SceneManager.Instance.TryGetScene(x, y, out neighbourScene);

                TestClient neighbourTc = new TestClient(newAgent, neighbourScene);
                neighbourTcs.Add(neighbourTc);
                neighbourScene.AddNewClient(neighbourTc, PresenceType.User);
            };
        }
开发者ID:hippie-b,项目名称:opensim,代码行数:37,代码来源:EntityTransferHelpers.cs

示例10: DisposeDoesNothingWhenNotLoggedIn

 public void DisposeDoesNothingWhenNotLoggedIn()
 {
     var client = new TestClient();
     Assert.IsFalse(client.LoggedOut);
     client.Dispose();
     Assert.IsFalse(client.LoggedOut);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:7,代码来源:CruiseServerClientBaseTests.cs

示例11: BadDownload

        public void BadDownload()
        {
            var res = new MockResponse()
            {
                ContentType = "application/json",
                Code = System.Net.HttpStatusCode.Gone,
                Body = @"{ ""message"": ""Export no longer available."" }"
            };

            using (var c = new TestClient(res))
            {
                try
                {
                    c.Client.Export.Download(123);
                    Assert.Fail("should throw an exception");
                }
                catch (SlideRoom.API.SlideRoomAPIException e)
                {
                    Assert.AreEqual("Export no longer available.", e.Message);
                    Assert.AreEqual(System.Net.HttpStatusCode.Gone, e.StatusCode);
                }
                catch
                {
                    Assert.Fail("should throw a SlideRoomAPIException");
                }
            }
        }
开发者ID:ryanlsmith,项目名称:api-csharp,代码行数:27,代码来源:Download.cs

示例12: FlyToCommand

        public FlyToCommand(TestClient client)
        {
            Name = "FlyTo";
            Description = "Fly the avatar toward the specified position for a maximum of seconds. Usage: FlyTo x y z [seconds]";
            Category = CommandCategory.Movement;

            client.Objects.OnObjectUpdated += new ObjectManager.ObjectUpdatedCallback(Objects_OnObjectUpdated);
        }
开发者ID:3di,项目名称:3di-viewer-rei-libs,代码行数:8,代码来源:FlyToCommand.cs

示例13: DisposeLogsOutWhenLoggedIn

 public void DisposeLogsOutWhenLoggedIn()
 {
     var client = new TestClient();
     Assert.IsFalse(client.LoggedOut);
     client.Login(new { });
     client.Dispose();
     Assert.IsTrue(client.LoggedOut);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:8,代码来源:CruiseServerClientBaseTests.cs

示例14: T01_Successful2

        public void T01_Successful2()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetConnectableIP(), GetConnectablePort()));
            t.WaitAndClose();

            Assert.IsTrue(c.Succeeded);
        }
开发者ID:FNKGino,项目名称:poderosa,代码行数:9,代码来源:InterruptableConnectorT.cs

示例15: T05_NotConnectable3

        public void T05_NotConnectable3()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetConnectableDNSName(), GetClosedPort())); //ホストはあるがポートが開いてない
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable3 [{0}]", c.ErrorMessage));
        }
开发者ID:FNKGino,项目名称:poderosa,代码行数:10,代码来源:InterruptableConnectorT.cs


注:本文中的TestClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。