Example #1
0
        public void Process_NewCommitteeEvent_SetsCommitteeProperties()
        {
            var id = Guid.NewGuid();
            var @event = new NewCommitteeEvent(id, "Test Committee", "mandate");
            var department = new Department();
            department.Process(@event);

            var committee = department.Committees.First();
            Assert.Equal(id, committee.Id);
            Assert.Equal("Test Committee", committee.Name);
        }
Example #2
0
        public async Task Publish_ToSubscribedEvent_RunsTask()
        {
            var ev = new NewCommitteeEvent(Guid.NewGuid(), "Test Committee", "mandate");
            bool hasRun = false;
            Action<object, IDictionary<string, string>> action = (o, h) => hasRun = true;

            using (var bus = new InMemoryBus())
            {
                await bus.Subscribe<NewCommitteeEvent>(action);
                await bus.Publish(ev);
                await bus.Start();
                Thread.Sleep(20);//give task time to complete
            }
            
            Assert.True(hasRun);
        }
Example #3
0
        public async Task Publish_ToUnsubscribedEvent_NothingHappens()
        {
            var ev = new NewCommitteeEvent(Guid.NewGuid(), "Test Committee", "mandate");
            bool hasRun = false;
            Action<object, IDictionary<string, string>> action = (o, h) => hasRun = true;

            using (var bus = new InMemoryBus())
            {
                await bus.Subscribe<NewDepartmentEvent>(action);
                await bus.Publish(ev);
                await bus.Start();
                Thread.Sleep(20);
            }
            
            Assert.False(hasRun);
        }
Example #4
0
        public void Process(NewCommitteeEvent @event)
        {
            var committee = new Committee()
            {
                Id = @event.Id,
                Name = @event.Name,
                Mandate = @event.Mandate,
                IsActive = true
            };

            committees.Add(committee);
        }