Пример #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);
        }
Пример #2
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);
        }