public void Ctor_ISocketFactoryMock_PropertySocketFactoryDeliversDefault() { var socketFactoryMock = new Mock<ISocketFactory>(); var instance = new DiceConnectionFactory(socketFactoryMock.Object); Assert.True(socketFactoryMock.Object.Equals(instance.SocketFactory)); }
public async Task<ConnectionCreated> Create(CreateConnectionCommand createConnection) { IDiceConnectionFactory connectionFactory = new DiceConnectionFactory(); try { var game = await GamesContext.GetInstance().GetAsync(createConnection.GameId); if (game != null) { var gameConnection = await game.ConnectionFactory.CreateAsync(new GameConnectionInfo() { HostName = createConnection.HostName, Port = createConnection.Port }); var hostedConnection = new HostedConnection(createConnection.HostName, createConnection.Port, gameConnection); gameConnection.GameDataReceived += (sender, e) => { MessageHubProxy.Invoke("SendMessage", hostedConnection.Id, e.GameData.DataString); }; this.ConnectionHost.Add(hostedConnection); var connection = new Connection() { Id = hostedConnection.Id, HostName = createConnection.HostName, Port = createConnection.Port }; return new ConnectionCreated(hostedConnection.Id, connection); } var responseMessage = new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent(string.Format("Game with id '{0}' was not found.", createConnection.GameId)), }; throw new HttpResponseException(responseMessage); } catch (Exception ex) { var responseMessage = new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent(ex.Message), }; throw new HttpResponseException(responseMessage); } }
public void Ctor_None_PropertySocketFactoryDeliversDefault() { var instance = new DiceConnectionFactory(); Assert.IsType<SocketFactory>(instance.SocketFactory); }
public void Ctor_None_ImplementsIDiceConnectionFactory() { var instance = new DiceConnectionFactory(); Assert.IsAssignableFrom<IDiceConnectionFactory>(instance); }
public DiceConnectionFactoryTest() { socketFactoryMock = new Mock<ISocketFactory>(); connectionFactory = new DiceConnectionFactory(socketFactoryMock.Object); }