Skip to content

Commit

Permalink
KnowsWhenItIsIdle
Browse files Browse the repository at this point in the history
  • Loading branch information
chad committed Feb 10, 2010
1 parent 8d406f6 commit 3a802d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion resque-sharp/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ public bool IsWorking()
{
return state() == "working";
}

public object IsIdle()
{
return state() == "idle";
}
public string state()
{
return Resque.redis().ContainsKey("resque:worker:" + workerId()) ? "working" : "idle";
Expand All @@ -155,5 +158,7 @@ internal string workerId()
{
return "FIXME";
}


}
}
7 changes: 7 additions & 0 deletions tests/WorkerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@ public void KnowsWhenItsWorking()
worker.work(0, (Job Job) => {Assert.That(worker.IsWorking(), Is.True); return true;});
}

[Test]
public void KnowsWhenItIsIdle()
{
worker.work(0);
Assert.That(worker.IsIdle(), Is.True);
}

}
}

0 comments on commit 3a802d5

Please sign in to comment.