コード例 #1
0
        public ScreenTests()
        {
            DomainEvents.ClearCallbacks();

            testPresentation1 = Presentation.Create("testPresentation1", null, null, null, "media/medium1.mp4");
            testPresentation2 = Presentation.Create("testPresentation2", null, null, null, "media/medium2.mp4");
        }
コード例 #2
0
        public void SetUp()
        {
            DomainEvents.ClearCallbacks();

            testAppointment1 = Appointment.Create(testScheduleId,
                                                  testClientId, testPatientId, testRoomId, testStartTime, testEndTime,
                                                  testAppointmentTypeId, testDoctorId, "testAppointment1");
        }
コード例 #3
0
        public void Should_RemoveEvent_ToListOf_RegisteredEvents()
        {
            DomainEvents.Register <FakeEvent>(x => Console.Write("Registered"));
            DomainEvents.ClearCallbacks();

            var actions = (List <Delegate>) typeof(DomainEvents).GetField("actions", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);

            actions.Should().HaveCount(0);
        }
コード例 #4
0
        public async Task ClearDomainEventsCallback()
        {
            DomainEvents.Register <ChangeSong>(song => Assert.Fail());

            DomainEvents.ClearCallbacks();

            await DomainEvents.RaiseAsync(new ChangeSong());

            Assert.Pass();
        }
コード例 #5
0
        public void RaiseAppointmentCreatedEvent()
        {
            string testCustomerEmail       = "*****@*****.**";
            string notificationSentToEmail = "";

            DomainEvents.ClearCallbacks();
            DomainEvents.Register <AppointmentCreated>(ac => notificationSentToEmail = ac.Appointment.EmailAddress);

            var appointment = Appointment.Create(testCustomerEmail);

            Assert.AreEqual(testCustomerEmail, notificationSentToEmail);
        }
コード例 #6
0
        public void CallHandleOnTestHandlerWhenRaiseIsCalled()
        {
            var testCounterName = "testCounterName" + Guid.NewGuid();

            DomainEvents.Container = _container;
            DomainEvents.ClearCallbacks();
            var counter = new Counter(testCounterName);

            counter.Increment(); // should call TestHandler

            Assert.AreEqual(testCounterName, TestHandlerHandledEvent.CounterName);
        }
コード例 #7
0
        public void ActionEventHanlderShouldBeExecuted()
        {
            var handlerExecuted = false;

            DomainEvents.ClearCallbacks();

            DomainEvents.Register <SampleDomainEvent>(e => handlerExecuted = true);

            DomainEvents.Raise <SampleDomainEvent>();

            Assert.IsTrue(handlerExecuted);
        }
コード例 #8
0
        public void DomainEventHandlerShouldBeExecuted()
        {
            DomainEvents.ClearCallbacks();

            var sampleDomainEventHandler = new SampleDomainEventHandler();

            DomainEvents.Register <SampleDomainEvent>(sampleDomainEventHandler);

            DomainEvents.Raise <SampleDomainEvent>();

            Assert.IsTrue(sampleDomainEventHandler.HandlerExecuted);
        }
コード例 #9
0
        public void CheckIfClearEventsWorks()
        {
            //Arrange
            var eventHandlerCallCount = 0;

            DomainEvents.Register <TestEvent>(e => { eventHandlerCallCount++; });

            //Act
            DomainEvents.ClearCallbacks();
            DomainEvents.Raise(new TestEvent()); // event is published after using statement

            //Assert
            Assert.Equal(0, eventHandlerCallCount);
        }
コード例 #10
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            using (DomainEvents.Register((AllTestsPassedEvent e) => Console.WriteLine("All tests passed!")))
            {
                DomainEvents.Raise(new AllTestsPassedEvent());
                DomainEvents.FailWith(new PreconditionFailedEvent());
            }

            DomainEvents.ClearCallbacks();

            Console.ReadKey();
        }
コード例 #11
0
        public void SetUp()
        {
            DomainEvents.ClearCallbacks();

            testDateTimeRange = new DateTimeRange(new DateTime(2014, 6, 9), new DateTime(2014, 6, 16));

            testAppointment1 = Appointment.Create(testScheduleId,
                                                  testClientId, testPatientId, testRoomId, testStartTime, testEndTime,
                                                  testAppointmentTypeId, testDoctorId, "testAppointment1");

            testAppointment2 = Appointment.Create(testScheduleId,
                                                  testClientId, testPatientId, testRoomId, testStartTime, testEndTime,
                                                  testAppointmentTypeId, testDoctorId, "testAppointment2");
        }
コード例 #12
0
        public void RaiseCounterIncrementedEvent()
        {
            string eventRaisedByCounter = "";
            int    currentCount         = 0;
            var    counter = new Counter(_testCounterName);

            DomainEvents.ClearCallbacks();
            DomainEvents.Register <CounterIncrementedEvent>(c =>
            {
                eventRaisedByCounter = c.CounterName;
                currentCount         = c.CounterCount;
            });

            counter.Increment();
            Assert.AreEqual(eventRaisedByCounter, _testCounterName);
            Assert.AreEqual(1, currentCount);
        }
コード例 #13
0
        public async Task DomainEventsSuccessfullyRaisesDomainEvent()
        {
            Domain.Track song = new Domain.Track
            {
                Artists = new List <Artist> {
                    new Artist {
                        Id = "123", Name = SONG_ARTIST
                    }
                },
                Length = SONG_LENGTH,
                Name   = SONG_TITLE,
                Id     = SONG_URI
            };

            DomainEvents.Register <ChangeTrack>(changedSong =>
            {
                Assert.AreEqual(PARTY_CODE, changedSong.PartyCode);
                Assert.AreEqual(song, changedSong.Track);
                Assert.AreEqual(PROGRESS_MS, changedSong.ProgressMs);
                Assert.Pass();
            });

            await DomainEvents.RaiseAsync(new ChangeTrack
            {
                PartyCode  = PARTY_CODE,
                ProgressMs = PROGRESS_MS,
                Track      = song,
                Listeners  = new List <PartyGoer>
                {
                    new PartyGoer(PARTY_GOER_ID_1, false, "US", "premium")
                }
            });

            DomainEvents.ClearCallbacks();

            // If event doesn't get raised,
            Assert.Fail();
        }
コード例 #14
0
        public void Book(BookAppointmentRequest request)
        {
            var session = _sessionFactory.OpenSession();

            CurrentSessionContext.Bind(session);

            try
            {
                using (var transactionScope = new TransactionScope())
                {
                    DomainEvents.Register <AppointmentBookedEvent>(AppointmentBooked);
                    Appointment.Book(request.ConsultantId, request.Id, request.Date, request.StartTime, request.EndTime, request.LeadName, request.Address);
                    session.Flush();
                    transactionScope.Complete();
                }
            }
            finally
            {
                CurrentSessionContext.Unbind(_sessionFactory);
                DomainEvents.ClearCallbacks();
                session.Dispose();
            }
        }
コード例 #15
0
        public void Update(UpdateHolidayRequest request)
        {
            var session = _sessionFactory.OpenSession();

            CurrentSessionContext.Bind(session);

            try
            {
                using (var transactionScope = new TransactionScope())
                {
                    var holiday = _holidayRepository.GetById(request.Id);
                    DomainEvents.Register <HolidayUpdatedEvent>(HolidayUpdated);
                    holiday.Update(request.Start, request.End);
                    session.Flush();
                    transactionScope.Complete();
                }
            }
            finally
            {
                CurrentSessionContext.Unbind(_sessionFactory);
                DomainEvents.ClearCallbacks();
                session.Dispose();
            }
        }
コード例 #16
0
 public DomainEventsTests()
 {
     DomainEvents.ClearCallbacks();
 }
コード例 #17
0
 private void Cleardown()
 {
     DomainEvents.ClearCallbacks();
     _sessionFactory.GetCurrentSession().Dispose();
     CurrentSessionContext.Unbind(_sessionFactory);
 }
コード例 #18
0
 public void Teardown()
 {
     DomainEvents.ClearCallbacks();
 }
コード例 #19
0
ファイル: PlaylistTests.cs プロジェクト: joedawalker/SpotSync
 public void ClearDomainEvents()
 {
     DomainEvents.ClearCallbacks();
 }