public void Set_GivenAuthenticatedUser_SetOnRepository()
    {
      var ext = Make_HeartbeatExtension();
      var state = new ClusterState();

      ext.Set(state);

      HeartbeatRepository.Verify(m => m.Set(It.IsAny<Octopus.Module.Data.Model.ClusterState>()));
    }
    public EndpointResult Set(ClusterState state = null)
    {
      if(Request.IsAnonymousUser) throw new InsufficientPermissionsException();

      HeartbeatRepository.Set(new Data.Model.ClusterState
        {
          JobsInQueue = state.JobsInQueue,
          Agents = state.Agents.Select(a => new Data.Model.AgentState
            {
              Hostname = a.Hostname,
              Port = a.Port,
              HasAvailableSlots = a.HasAvailableSlots,
              State = a.State
            }).ToList()
        });

      return EndpointResult.Success();
    }