コード例 #1
0
ファイル: CarProtoServer.cs プロジェクト: skohub/CarControl
 private void ClientConnected(object sender, AsyncCarClientToken e)
 {
     if (GetInputCommandFactory == null) return;
     var commandFactory = GetInputCommandFactory();
     var cp = new TextAuthProto(e, commandFactory, _nextId++, _carService);
     e.Proto = cp;
     _cars.Add(cp.Id, cp);
 }
コード例 #2
0
 public void MustNotAuthenticateText()
 {
     var tcpConnectionMock = new TcpConnectionMock();
     var carServiceMock = new CarServiceMock();
     var commandFactory = new InputCommandFactory(carServiceMock);
     var authProto = new TextAuthProto(tcpConnectionMock, commandFactory, 1, new CarServiceMock());
     authProto.Receive(Encoding.UTF8.GetBytes("123456789012345:12\r\n"));
     var expect = Encoding.UTF8.GetBytes("LOGINFAIL\r\n");
     CollectionAssert.AreEqual(tcpConnectionMock.LastSentBuf, expect);
 }
コード例 #3
0
 public void MustAuthenticateText()
 {
     var tcpConnectionMock = new TcpConnectionMock();
     var carServiceMock = new CarServiceMock();
     var commandFactory = new InputCommandFactory(carServiceMock);
     var authProto = new TextAuthProto(tcpConnectionMock, commandFactory, 1, carServiceMock);
     authProto.Receive(Encoding.UTF8.GetBytes("123456789012345:123\r\n"));
     var expect = Encoding.UTF8.GetBytes("LOGINOK\r\n");
     Assert.IsTrue(tcpConnectionMock.LastSentBuf.Length > 8);
     var ans = new byte[9];
     Array.Copy(tcpConnectionMock.LastSentBuf, ans, 9);
     CollectionAssert.AreEqual(ans, expect);
 }