public void it_should_send_it_out() { //Arrange MockFactory.CreateActor <EmailActor>(); //Act MockFactory.LocateActor(typeof(EmailActor)).Tell(new SendEmailMessage()); //Assert AwaitAssert(() => ExpectMsg <EmailSentMessage>()); }
public void it_should_send_it_out() { //Arrange MockFactory.CreateActor <EmailActor>(); var emailAddress = "*****@*****.**"; //Act MockFactory.LocateActor(typeof(EmailActor)).Tell(new SendEmailMessage(emailAddress)); //Assert AwaitAssert(() => ExpectMsg <EmailSentMessage>(message => message.EmailAddress == emailAddress)); }
public void it_should_do_a_pong_unit2() { //Arrange //mockFactory = new AkkaMockFactory(DependencyResolver.GetContainer(), Sys); MockFactory.CreateActor <PingCoordinatorActor <MockActor1, MockActor2> >(); //Act MockFactory.LocateActor(typeof(PingCoordinatorActor <,>)).Tell(new PingMessage()); //Assert AwaitAssert(() => ExpectMsg <SorryImStashing>(), TimeSpan.FromSeconds(20)); }
public void it_should_send_it_out2() { //Arrange MockFactory.UpdateContainer((builder) => builder.Register((r) => new TestEmailSender()).As <IEmailSender>()); MockFactory.CreateActor <EmailSupervisorActor <EmailActor> >(); var emailAddress = "*****@*****.**"; //Act MockFactory.LocateActor(typeof(EmailSupervisorActor <>)).Tell(new SendEmailMessage(emailAddress)); //Assert Xunit.Assert.Throws <AssertFailedException>(() => Assert.IsTrue(TestEmailSender.HasSentEmail)); }
public void it_should_send_it_out() { //Arrange MockFactory.UpdateContainer((builder) => builder.Register((r) => new TestEmailSender()).As <IEmailSender>()); MockFactory.CreateActor <EmailSupervisorActor <EmailActor> >(); var emailAddress = "*****@*****.**"; //Act MockFactory.LocateActor(typeof(EmailSupervisorActor <>)).Tell(new SendEmailMessage(emailAddress)); //Assert Xunit.Assert.Throws <TrueException>(() => AwaitAssert(() => ExpectMsg <EmailReadyToSendMessage>(message => message.EmailAddress == emailAddress))); }
public void it_should_send_it_out() { //Arrange MockFactory.UpdateContainer((builder) => builder.Register((r) => new TestEmailSender()).As <IEmailSender>()); MockFactory.CreateActor <EmailActor>(); var emailAddress = "*****@*****.**"; //Act MockFactory.LocateActor(typeof(EmailActor)).Tell(new SendEmailMessage(emailAddress)); //Assert AwaitAssert(() => ExpectMsg <EmailSentMessage>(message => message.EmailAddress == emailAddress)); Assert.IsTrue(TestEmailSender.HasSentEmail); }
public void it_should_send_it_out2() { //Arrange const string emailAddress = "*****@*****.**"; MockFactory.WhenActorReceives <SendEmailMessage>().ItShouldTellSender(new EmailSentMessage(emailAddress)).SetUpMockActor <MockActor>(); MockFactory.CreateActor <EmailSupervisorActor <MockActor> >(); //Act MockFactory.LocateActor(typeof(EmailSupervisorActor <>)).Tell(new SendEmailMessage(emailAddress)); //Assert AwaitAssert(() => ExpectMsg <EmailSentMessage>(message => message.EmailAddress == emailAddress), TimeSpan.FromMinutes(1)); }
public void it_should_send_it_out() { //Arrange MockFactory.CreateActor <EmailActor>(); var emailAddress = "*****@*****.**"; //Act MockFactory.LocateActor(typeof(EmailActor)).Tell(new SendEmailMessage(emailAddress)); //Assert AwaitAssert(() => ExpectMsg <EmailSentMessage>(message => message.EmailAddress == emailAddress)); Xunit.Assert.Throws <AssertFailedException>(() => Assert.IsTrue(TestEmailSender.HasSentEmail)); }
public void it_should_do_a_pong() { //Arrange MockFactory.UpdateContainer((builder) => { builder.Register <IPingPongService>(b => new FakePingPongService()); }); MockFactory.CreateActor <PingPongActor <MockActor> >(); //Act MockFactory.LocateActor(typeof(PingPongActor <>)).Tell(new PingMessage()); //Assert AwaitAssert(() => ExpectMsg <PingMessageCompleted>(), TimeSpan.FromSeconds(5)); }
public void it_should_send_it_out() { //Arrange var fakeEmailSender = A.Fake <IEmailSender>(); MockFactory.UpdateContainer((builder) => builder.Register((r) => fakeEmailSender)); MockFactory.CreateActor <EmailSupervisorActor <EmailActor> >(); var emailAddress = "*****@*****.**"; //Act MockFactory.LocateActor(typeof(EmailSupervisorActor <>)).Tell(new SendEmailMessage(emailAddress)); //Assert AwaitAssert(() => ExpectMsg <EmailReadyToSendMessage>(message => message.EmailAddress == emailAddress)); AwaitAssert(() => ExpectMsg <EmailSentMessage>(message => message.EmailAddress == emailAddress)); A.CallTo(() => fakeEmailSender.Send(emailAddress)).MustHaveHappened(); }
public void it_should_do_a_pong1() { //Arrange //mockFactory = new AkkaMockFactory(DependencyResolver.GetContainer(), Sys); MockFactory.WhenActorReceives <PingMessage>().ItShouldTellSender(new PongMessage()).CreateMockActor <MockActor>(); MockFactory.CreateActor <PingPongActor <MockActor> >(); //Act MockFactory.LocateActor(typeof(PingPongActor <>)).Tell(new PingMessage()); //Assert AwaitAssert(() => ExpectMsg <PingMessageCompleted>(), TimeSpan.FromSeconds(5)); AwaitAssert(() => ExpectMsg <PongMessage>(), TimeSpan.FromSeconds(5)); AwaitAssert(() => MockFactory.ExpectMockActor(typeof(MockActor)).WhoseParentIs(MockFactory.LocateActor(typeof(PingPongActor <>))).ToHaveReceivedMessage <PingMessage>(), TimeSpan.FromSeconds(5)); }
public void it_should_do_a_pong_unit2() { // var container = new ContainerBuilder().Build(); // mockFactory = new AkkaMockFactory(container, Sys); MockFactory.UpdateContainer((builder) => { builder.Register <IPingPongService>(b => new FakePingPongService()); }); //Arrange MockFactory.CreateActor <PingCoordinatorActor <MockActor1, MockActor2> >(); //Act MockFactory.LocateActor(typeof(PingCoordinatorActor <,>)).Tell(new PingMessage()); //Assert AwaitAssert(() => ExpectMsg <SorryImStashing>(), TimeSpan.FromSeconds(20)); }
public void it_should_do_a_pong_unit1() { //Arrange //mockFactory = new AkkaMockFactory(DependencyResolver.GetContainer(), Sys); MockFactory.CreateActor <PingPongActor <MockActor> >(); //Act for (var i = 0; i < 10; i++) { System.Threading.Thread.Sleep(1000); MockFactory.LocateActor(typeof(PingPongActor <>)).Tell(new PingMessage()); } //Assert AwaitAssert(() => ExpectMsg <PingMessageCompleted>(), TimeSpan.FromSeconds(20)); }
public void it_should_send_it_out() { //Arrange MockFactory.UpdateContainer((builder) => builder.Register((r) => new TestEmailSender()).As <IEmailSender>()); MockFactory.CreateActor <EmailSupervisorActor <MockActor> >(); var emailAddress = "*****@*****.**"; //Act MockFactory.LocateActor(typeof(EmailSupervisorActor <>)).Tell(new SendEmailMessage(emailAddress)); //Assert AwaitAssert(() => ExpectMsg <EmailReadyToSendMessage>(message => message.EmailAddress == emailAddress)); /* * BECAUSE WE ARE TESTING SUPERVISOR IN ISOLATION!!! * AwaitAssert(() => ExpectMsg<EmailSentMessage>(message => message.EmailAddress == emailAddress)); * Assert.IsTrue(TestEmailSender.HasSentEmail); */ }
public void it_should_do_a_pong() { //Arrange MockFactory.CreateActor <PingPongActor <MockActor> >(); //Act MockFactory.LocateActor(typeof(PingPongActor <>)).Tell(new PingMessage()); try { //Assert AwaitAssert(() => ExpectMsg <PingMessageCompleted>(), TimeSpan.FromSeconds(5)); AwaitAssert(() => ExpectMsg <PongMessage>(), TimeSpan.FromSeconds(5)); throw new Exception(); } catch (Exception) { } }
public void it_should_do_a_pong_integration() { //Arrange //var container = new ContainerBuilder().Build(); // mockFactory = new AkkaMockFactory(container, Sys); MockFactory.UpdateContainer((builder) => { builder.Register <IPingPongService>(b => new FakePingPongService()); }); MockFactory.CreateActor <PingPongActor <PingCoordinatorActor <PingActor, PingBlockingActor> > >(); //Act for (var i = 0; i < 10; i++) { System.Threading.Thread.Sleep(1000); MockFactory.LocateActor(typeof(PingPongActor <>)).Tell(new PingMessage()); } //Assert AwaitAssert(() => ExpectMsg <PongMessage>(), TimeSpan.FromSeconds(20)); }