Пример #1
0
 public void GetUsers_Returns_Non_Null_Collection()
 {
     KudosRepository target = new KudosRepository();
     IEnumerable<User> users = target.GetUsers();
     Assert.IsNotNull(users);
     Assert.AreNotEqual(0, users.Count());
 }
Пример #2
0
        public static void Begin()
        {
            var repository = new KudosRepository();
            var hubContext = GlobalHost.ConnectionManager.GetHubContext<EventHub>();

            Task.Factory.StartNew(() =>
            {
                DateTime lastUpdate = DateTime.Now;
                CancellationToken token = tokenSource.Token;

                while (true)
                {
                    token.ThrowIfCancellationRequested();

                    // check for updates since the last check
                    // get the group(s)
                    // publish the update
                    var recentKudos = repository.GetLatestKudos(lastUpdate);

                    // SELECT N + 1
                    // what I really want here is networks by latest kudos.
                    // so lets just do THAT
                    foreach (var recent in recentKudos)
                    {
                        var network = repository.GetUserNetwork(recent.ReceiverId);
                        var group = hubContext.Clients.Group(network.Id).echo("cool");
                    }

                    lastUpdate = DateTime.Now;

                    Thread.Sleep(500);
                }
            }, TaskCreationOptions.LongRunning);
        }
Пример #3
0
        public void GetUserNetwork_For_Existing_User_Returns_Network()
        {
            var target = new KudosRepository();
            var network = target.GetUserNetwork("rjennings");

            Assert.IsNotNull(network);
        }
Пример #4
0
        public void GetTopPraiseStatistics()
        {
            KudosRepository target = new KudosRepository();

            var stats = target.GetTopStatistics();

            Assert.IsNotNull(stats);
        }
Пример #5
0
        public void GetStatistics_ByUser_Returns_Non_Null_Collection()
        {
            KudosRepository target = new KudosRepository();

            var stats = target.GetStatistics("users/4");

            Assert.IsNotNull(stats);
        }
Пример #6
0
        public void FindUser_Exact_Match_Returns_Single_Match_User()
        {
            KudosRepository target = new KudosRepository();
            var result = target.FindUser("Ross Jennings");

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.MatchedUsers);
        }
Пример #7
0
        public void FindUser_Incomplete_Returns_Suggested_Users()
        {
            KudosRepository target = new KudosRepository();
            var result = target.FindUser("Rossy");

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Suggestions);
            Assert.IsTrue(result.Suggestions.Length > 0);
        }
Пример #8
0
        public override Task OnConnected()
        {
            // todo: get the ravendb "network" for this user.
            // add this connection to the SignalR group for this network
            var user = Context.User;
            var repo = new KudosRepository();
            var network = repo.GetUserNetwork(user.Identity.Name);

            //	slightly easier, member of one network
            if (network != null)
            {
                Groups.Add(Context.ConnectionId, network.Id);
            }

            // todo: map one member to MANY networks
            return base.OnConnected();
        }