public void OnTimer_should_poll_broker() { bus.Stub(x => x.Publish(Arg <Messages.BrokerStatus> .Is.Anything)).WhenCalled(x => { var status = x.Arguments[0] as Messages.BrokerStatus; if (status == null) { Console.WriteLine("Argument 0 is not BrokerStatus"); return; } Console.WriteLine("IsResponding: {0}", status.IsResponding); foreach (var vhost in status.VHosts) { Console.WriteLine("\tVhost: {0}", vhost.Name); foreach (var connection in vhost.Connections) { Console.WriteLine("\t\tConnection Name: {0}", connection.Name); foreach (var property in connection.ClientProperties) { Console.WriteLine("\t\t\t{0} -> {1}", property.Key, property.Value); } } } }); var brokers = new List <Broker> { new Broker { Url = "http://localhost:15672/", Username = "******", Password = "******", Active = true } }; dbReader.Stub(x => x.Get <Broker> ("Active = TRUE")).Return(brokers); harvesterService.OnTimer(null); bus.AssertWasCalled(x => x.Publish(Arg <Messages.BrokerStatus> .Is.Anything)); }