public NewConnectionTests() { _connectionSettings = new Mock <IOptions <PokerConnectionSettings> >(); _responseMessageParser = new Mock <IResponseMessageParser>(); _pokerConnection = new Mock <IPokerConnection>(); _userCacheProvider = new Mock <UserCacheProvider>(); _planningPokerService = new Mock <IPlanningPokerService>(); _planningConnectionFactory = new PlanningConnectionFactory(_connectionSettings.Object, _responseMessageParser.Object, _pokerConnection.Object, _userCacheProvider.Object, _planningPokerService.Object); }
public static IServiceCollection AddPlanningPokerClient(this IServiceCollection services, IConfigurationRoot configuration) { services.Configure <PokerConnectionSettings>(options => configuration.GetSection("PokerConnectionSettings").Bind(options)); var validatedConfiguration = IServiceCollectionExtension.ValidateAndRetrieveConfiguration(configuration); var connectionSettings = new PokerConnectionSettings( validatedConfiguration.PlanningSocketUri, validatedConfiguration.PlanningApiUri, validatedConfiguration.PlanningApiKey ); var connectionSettingsOptions = Options.Create(connectionSettings); var messageParser = new MessageParser(); services.AddSingleton(typeof(MessageParser), messageParser); var responseMessageFactories = new List <IResponseMessageFactory>(); responseMessageFactories.Add(new NewSessionResponseMessageFactory(messageParser)); responseMessageFactories.Add(new SubscribeSessionResponseMessageFactory(messageParser)); responseMessageFactories.Add(new JoinSessionResponseMessageFactory(messageParser)); responseMessageFactories.Add(new RefreshSessionMessageFactory(messageParser)); responseMessageFactories.Add(new EndSessionClientMessageFactory(messageParser)); var responseMessageParser = new ResponseMessageParser(messageParser, responseMessageFactories); services.AddSingleton(typeof(IResponseMessageParser), responseMessageParser); var planningPokerSocket = new PlanningPokerSocket(connectionSettingsOptions); services.AddSingleton(typeof(IPokerConnection), planningPokerSocket); var userCacheProvider = new UserCacheProvider(); services.AddSingleton(typeof(UserCacheProvider), userCacheProvider); var httpClient = new HttpClient(); services.AddSingleton(typeof(HttpClient), httpClient); var planningPokerApiService = new PlanningPokerApiService(httpClient, connectionSettingsOptions); services.AddSingleton(typeof(IPlanningPokerService), planningPokerApiService); var planningPokerConnectionFactory = new PlanningConnectionFactory(connectionSettingsOptions, responseMessageParser, planningPokerSocket, userCacheProvider, planningPokerApiService); services.AddSingleton(typeof(IPlanningConnectionFactory), planningPokerConnectionFactory); services = AddResponseMessageFactories(services); return(services); }
public void GivenConstructorIsCalled_WhenValidParametersArePassed_ThenConsturctionSuceeds() { var result = new PlanningConnectionFactory(_connectionSettings.Object, _responseMessageParser.Object, _pokerConnection.Object, _userCacheProvider.Object, _planningPokerService.Object); Assert.NotNull(result); }