public ScreenTests() { DomainEvents.ClearCallbacks(); testPresentation1 = Presentation.Create("testPresentation1", null, null, null, "media/medium1.mp4"); testPresentation2 = Presentation.Create("testPresentation2", null, null, null, "media/medium2.mp4"); }
public void SetUp() { DomainEvents.ClearCallbacks(); testAppointment1 = Appointment.Create(testScheduleId, testClientId, testPatientId, testRoomId, testStartTime, testEndTime, testAppointmentTypeId, testDoctorId, "testAppointment1"); }
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); }
public async Task ClearDomainEventsCallback() { DomainEvents.Register <ChangeSong>(song => Assert.Fail()); DomainEvents.ClearCallbacks(); await DomainEvents.RaiseAsync(new ChangeSong()); Assert.Pass(); }
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); }
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); }
public void ActionEventHanlderShouldBeExecuted() { var handlerExecuted = false; DomainEvents.ClearCallbacks(); DomainEvents.Register <SampleDomainEvent>(e => handlerExecuted = true); DomainEvents.Raise <SampleDomainEvent>(); Assert.IsTrue(handlerExecuted); }
public void DomainEventHandlerShouldBeExecuted() { DomainEvents.ClearCallbacks(); var sampleDomainEventHandler = new SampleDomainEventHandler(); DomainEvents.Register <SampleDomainEvent>(sampleDomainEventHandler); DomainEvents.Raise <SampleDomainEvent>(); Assert.IsTrue(sampleDomainEventHandler.HandlerExecuted); }
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); }
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(); }
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"); }
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); }
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(); }
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(); } }
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(); } }
public DomainEventsTests() { DomainEvents.ClearCallbacks(); }
private void Cleardown() { DomainEvents.ClearCallbacks(); _sessionFactory.GetCurrentSession().Dispose(); CurrentSessionContext.Unbind(_sessionFactory); }
public void Teardown() { DomainEvents.ClearCallbacks(); }
public void ClearDomainEvents() { DomainEvents.ClearCallbacks(); }