Skip to content

Commit

Permalink
Adding more contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
agross committed Apr 19, 2012
1 parent 328b437 commit 47be2c4
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions AssemblyContextSpecs/Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ class FooEvent : IDomainEvent

public class DomainEventsContext : IAssemblyContext
{
internal static IList<IDomainEvent> Events = new List<IDomainEvent>();
internal static IList<IDomainEvent> Events;

public void OnAssemblyStart()
{
Events = new List<IDomainEvent>();

DomainEvents.RegisterEventPublisher(x => Events.Add(x));
}

Expand All @@ -47,11 +49,63 @@ public void OnAssemblyComplete()
}
}

public class When_a_domain_event_is_raised
public class When_a_domain_event_is_raised_1
{
Because of = () => DomainEvents.Raise(new FooEvent());

It should_capture_the_event =
() => DomainEventsContext.Events.ShouldContain(x => x.GetType() == typeof(FooEvent));

It should_have_at_least_one_event =
() =>
{
Console.WriteLine("\r\n# of captured events: " + DomainEventsContext.Events.Count);
DomainEventsContext.Events.Count.ShouldBeGreaterThan(0);
};
}

public class When_a_domain_event_is_raised_2
{
Because of = () => DomainEvents.Raise(new FooEvent());

It should_capture_the_event =
() => DomainEventsContext.Events.ShouldContain(x => x.GetType() == typeof(FooEvent));

It should_have_at_least_one_event =
() =>
{
Console.WriteLine("\r\n# of captured events: " + DomainEventsContext.Events.Count);
DomainEventsContext.Events.Count.ShouldBeGreaterThan(0);
};
}

public class When_a_domain_event_is_raised_3
{
Because of = () => DomainEvents.Raise(new FooEvent());

It should_capture_the_event =
() => DomainEventsContext.Events.ShouldContain(x => x.GetType() == typeof(FooEvent));

It should_have_at_least_one_event =
() =>
{
Console.WriteLine("\r\n# of captured events: " + DomainEventsContext.Events.Count);
DomainEventsContext.Events.Count.ShouldBeGreaterThan(0);
};
}

public class When_a_domain_event_is_raised_4
{
Because of = () => DomainEvents.Raise(new FooEvent());

It should_capture_the_event =
() => DomainEventsContext.Events.ShouldContain(x => x.GetType() == typeof(FooEvent));

It should_have_at_least_one_event =
() =>
{
Console.WriteLine("\r\n# of captured events: " + DomainEventsContext.Events.Count);
DomainEventsContext.Events.Count.ShouldBeGreaterThan(0);
};
}
}

0 comments on commit 47be2c4

Please sign in to comment.