本文整理汇总了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);
};
}
示例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;
}
示例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));
}
示例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);
}
}
示例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)));
}
示例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>();
}
开发者ID:RobinLaerm,项目名称:Fohjin,代码行数:7,代码来源:When_instantiating_two_of_the_same_aggregate_roots_it_will_wire_the_events_correctly_without_mixing_them_together.cs
示例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");
}
}
}
示例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);
}
}
示例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);
};
}
示例10: DisposeDoesNothingWhenNotLoggedIn
public void DisposeDoesNothingWhenNotLoggedIn()
{
var client = new TestClient();
Assert.IsFalse(client.LoggedOut);
client.Dispose();
Assert.IsFalse(client.LoggedOut);
}
示例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");
}
}
}
示例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);
}
示例13: DisposeLogsOutWhenLoggedIn
public void DisposeLogsOutWhenLoggedIn()
{
var client = new TestClient();
Assert.IsFalse(client.LoggedOut);
client.Login(new { });
client.Dispose();
Assert.IsTrue(client.LoggedOut);
}
示例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);
}
示例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));
}