Ejemplo n.º 1
0
        public UnitOfWorkContextTestsFixture SetEventsOnSeparateThreads()
        {
            var fooEvent = new FooEvent {
                Created = Now
            };
            var barEvent = new BarEvent {
                Created = Now
            };

            Events.Add(fooEvent);
            Events.Add(barEvent);

            var tasks = new List <Task>
            {
                Task.Run(() =>
                {
                    UnitOfWorkContextInstance.AddEvent(fooEvent);
                    UnitOfWorkContextInstance.AddEvent <FooEvent>(e => e.Created = Now);
                }),
                Task.Run(() =>
                {
                    UnitOfWorkContext.AddEvent(barEvent);
                    UnitOfWorkContext.AddEvent <BarEvent>(e => e.Created = Now);
                })
            };

            Task.WhenAll(tasks).GetAwaiter().GetResult();

            Now = DateTime.UtcNow;

            return(this);
        }
 public EventPublisherTestsFixture()
 {
     FooEvent = new FooEvent {
         Created = DateTime.UtcNow
     };
     BarEvent          = e => e.Created = DateTime.Now;
     UnitOfWorkContext = new Mock <IUnitOfWorkContext>();
     EventPublisher    = new EventPublisher(UnitOfWorkContext.Object);
 }
Ejemplo n.º 3
0
        public UnitOfWorkContextTestsFixture SetEvents()
        {
            var fooEvent = new FooEvent {
                Created = Now
            };
            var barEvent = new BarEvent {
                Created = Now
            };

            Events.Add(fooEvent);
            Events.Add(barEvent);

            UnitOfWorkContextInstance.AddEvent(fooEvent);
            UnitOfWorkContextInstance.AddEvent <FooEvent>(e => e.Created = Now);
            UnitOfWorkContext.AddEvent(barEvent);
            UnitOfWorkContext.AddEvent <BarEvent>(e => e.Created = Now);

            Now = DateTime.UtcNow;

            return(this);
        }