예제 #1
0
        public void SetupHere()
        {
            var chatAuthenticationService = new Mock <IChatAuthenticationService>();

            chatAuthenticationService.Setup(m => m.GetUser(It.IsAny <string>()))
            .ReturnsAsync(new ChatUser("peter#123", "AB", new ProfilePicture()));
            _chatAuthenticationService = chatAuthenticationService.Object;
            _banRepository             = new Mock <IBanRepository>().Object;
            _connectionMapping         = new ConnectionMapping();
            _chatHistory        = new ChatHistory();
            _settingsRepository = new SettingsRepository(MongoClient);
            _chatHub            = new ChatHub(_chatAuthenticationService, _banRepository, _settingsRepository,
                                              _connectionMapping, _chatHistory, null, null);

            var clients = new Mock <IHubCallerClients>();

            clients.Setup(c => c.Group(It.IsAny <string>())).Returns(new Mock <IClientProxy>().Object);
            clients.Setup(c => c.Caller).Returns(new Mock <IClientProxy>().Object);
            _chatHub.Clients = clients.Object;

            var context = new Mock <HubCallerContext>();

            context.Setup(c => c.ConnectionId).Returns("TestId");
            _chatHub.Context = context.Object;
            _chatHub.Groups  = new Mock <IGroupManager>().Object;
        }
예제 #2
0
 public ChatHub(
     IChatAuthenticationService authenticationService,
     IBanRepository banRepository,
     SettingsRepository settingsRepository,
     ConnectionMapping connections,
     ChatHistory chatHistory,
     IHttpContextAccessor contextAccessor,
     IWebsiteBackendRepository websiteBackendRepository)
 {
     _authenticationService    = authenticationService;
     _banRepository            = banRepository;
     _settingsRepository       = settingsRepository;
     _connections              = connections;
     _chatHistory              = chatHistory;
     _contextAccessor          = contextAccessor;
     _websiteBackendRepository = websiteBackendRepository;
 }