Exemplo n.º 1
0
        private void CompleteIfPossible()
        {
            if (Data.LeadSignedUpReceived && Data.InitializeClientReceived)
            {
                DomainEvents.Register <ClientInitializedDomainEvent>(ClientInitializedDomainEventHandler);
                var services = ServiceRepository.GetByIds(Data.AgreementServiceIds);

                Client.Initialize(
                    Data.ClientId,
                    Data.ClientName,
                    Data.ClientAddress1,
                    Data.ClientAddress2,
                    Data.ClientAddress3,
                    Data.ClientPhoneNumber,
                    Data.ClientEmailAddress,
                    Data.DealId,
                    Data.AgreementCommencement,
                    Data.AgreementExpiry,
                    services);

                MarkAsComplete();
                ClientRepository.Flush();
            }
        }
Exemplo n.º 2
0
 public BookingUpdatedHandler(ITimeAllocationRepository timeAllocationRepository)
 {
     _timeAllocationRepository = timeAllocationRepository;
     DomainEvents.Register <TimeAllocationUpdatedEvent>(TimeAllocationUpdated);
 }
Exemplo n.º 3
0
 public ExternalSpeaker()
 {
     DomainEvents.Register <DiskInsertedEvent>((e) => { TurnOn(); });
     DomainEvents.Register <DiskEjectedEvent>((e) => { TurnOff(); });
 }
Exemplo n.º 4
0
 void OnEnable( )
 {
     DomainEvents.Register <OnGameStarted> (OnGameStarted);
 }
Exemplo n.º 5
0
 public void TestRaiseShouldRaiseARegisteredEvent()
 {
     DomainEvents.Register <FakeDomainEvent>(p => { _wasHandled = true; });
     DomainEvents.Raise(_event);
     Assert.That(_wasHandled, Is.True);
 }
Exemplo n.º 6
0
 public void Initialize()
 {
     DomainEvents.Register <CallStatusChanged>(CallStatusChanged);
     busylightAdapter.TurnBlue();
 }
Exemplo n.º 7
0
 void OnEnable() => DomainEvents.Register <OnManaChanged>(HandleManaChanged);
        public void CanTransportFromHongkongToStockholm()
        {
            /* Test setup: A cargo should be shipped from Hongkong to Stockholm,
             * and it should arrive in no more than two weeks. */
            Location origin          = HONGKONG;
            Location destination     = STOCKHOLM;
            DateTime arrivalDeadline = new DateTime(2009, 3, 18);

            /* Use case 1: booking
             *
             * A new cargo is booked, and the unique tracking id is assigned to the cargo. */
            TrackingId trackingId = BookingService.BookNewCargo(
                origin.UnLocode, destination.UnLocode, arrivalDeadline
                );

            /* The tracking id can be used to lookup the cargo in the repository.
             *
             * Important: The cargo, and thus the domain model, is responsible for determining
             * the status of the cargo, whether it is on the right track or not and so on.
             * This is core domain logic.
             *
             * Tracking the cargo basically amounts to presenting information extracted from
             * the cargo aggregate in a suitable way. */
            Cargo cargo = CargoRepository.Find(trackingId);

            Assert.IsNotNull(cargo);

            /* Use case 2: routing
             *
             * A number of possible routes for this cargo is requested and may be
             * presented to the customer in some way for him/her to choose from.
             * Selection could be affected by things like price and time of delivery,
             * but this test simply uses an arbitrary selection to mimic that process.
             *
             * The cargo is then assigned to the selected route, described by an itinerary. */
            IList <Itinerary> itineraries = BookingService.RequestPossibleRoutesForCargo(trackingId);
            Itinerary         itinerary   = SelectPreferedItinerary(itineraries);

            using (DomainEvents.Register <CargoWasAssignedToRouteEvent>(x =>
            {
                Assert.AreEqual(TransportStatus.NotReceived, x.Delivery.TransportStatus);
                Assert.AreEqual(RoutingStatus.Routed, x.Delivery.RoutingStatus);
                Assert.IsNotNull(x.Delivery.EstimatedTimeOfArrival);
                Assert.AreEqual(new HandlingActivity(HandlingEventType.Receive, HONGKONG), x.Delivery.NextExpectedActivity);
            }))
            {
                BookingService.AssignCargoToRoute(trackingId, itinerary);
            }

            /*
             * Use case 3: handling
             *
             * A handling event registration attempt will be formed from parsing
             * the data coming in as a handling report either via
             * the web service interface or as an uploaded CSV file.
             *
             * The handling event factory tries to create a HandlingEvent from the attempt,
             * and if the factory decides that this is a plausible handling event, it is stored.
             * If the attempt is invalid, for example if no cargo exists for the specfied tracking id,
             * the attempt is rejected.
             *
             * Handling begins: cargo is received in Hongkong.
             */
            using (DomainEvents.Register <CargoWasHandledEvent>(x =>
            {
                Assert.AreEqual(TransportStatus.InPort, x.Delivery.TransportStatus);
                Assert.AreEqual(HONGKONG, x.Delivery.LastKnownLocation);
            }))
            {
                HandlingEventService.RegisterHandlingEvent(
                    new DateTime(2009, 3, 1), trackingId, HONGKONG.UnLocode, HandlingEventType.Receive
                    );
            }

            using (DomainEvents.Register <CargoWasHandledEvent>(x =>
            {
                // Check current state - should be ok
                Assert.AreEqual(HONGKONG, x.Delivery.LastKnownLocation);
                Assert.AreEqual(TransportStatus.OnboardCarrier, x.Delivery.TransportStatus);
                Assert.IsFalse(x.Delivery.IsMisdirected);
                Assert.AreEqual(new HandlingActivity(HandlingEventType.Unload, NEWYORK), x.Delivery.NextExpectedActivity);
            }))
            {
                // Next event: Load onto voyage CM003 in Hongkong
                HandlingEventService.RegisterHandlingEvent(
                    new DateTime(2009, 3, 3), trackingId, HONGKONG.UnLocode, HandlingEventType.Load
                    );
            }


            /*
             * Here's an attempt to register a handling event that's not valid
             * because there is no voyage with the specified voyage number,
             * and there's no location with the specified UN Locode either.
             *
             * This attempt will be rejected and will not affect the cargo delivery in any way.
             */
            //VoyageNumber noSuchVoyageNumber = new VoyageNumber("XX000");
            //UnLocode noSuchUnLocode = new UnLocode("ZZZZZ");
            //try
            //{
            //   HandlingEventService.RegisterHandlingEvent(
            //   new DateTime(2009, 3, 5), trackingId, noSuchUnLocode, HandlingEventType.Load
            //   );
            //   Assert.Fail("Should not be able to register a handling event with invalid location and voyage");
            //}
            //catch (ArgumentException)
            //{
            //}

            using (DomainEvents.Register <CargoWasHandledEvent>(x =>
            {
                // Check current state - cargo is misdirected!
                Assert.AreEqual(TOKYO, x.Delivery.LastKnownLocation);
                Assert.AreEqual(TransportStatus.InPort, x.Delivery.TransportStatus);
                Assert.IsTrue(x.Delivery.IsMisdirected);
                Assert.IsNull(x.Delivery.NextExpectedActivity);
            }))
            {
                // Cargo is now (incorrectly) unloaded in Tokyo
                HandlingEventService.RegisterHandlingEvent(
                    new DateTime(2009, 3, 5), trackingId, TOKYO.UnLocode, HandlingEventType.Unload
                    );
            }

            // -- Cargo needs to be rerouted --

            // TODO cleaner reroute from "earliest location from where the new route originates"

            // Specify a new route, this time to Goeteborg.
            using (DomainEvents.Register <CargoDestinationChangedEvent>(x =>
            {
                // The old itinerary does not satisfy the new specification
                Assert.AreEqual(RoutingStatus.Misrouted, x.Delivery.RoutingStatus);
                Assert.IsNull(x.Delivery.NextExpectedActivity);
            }))
            {
                cargo.SpecifyNewRoute(GOETEBORG);
            }

            // Repeat procedure of selecting one out of a number of possible routes satisfying the route spec
            IList <Itinerary> newItineraries = BookingService.RequestPossibleRoutesForCargo(cargo.TrackingId);
            Itinerary         newItinerary   = SelectPreferedItinerary(newItineraries);

            using (DomainEvents.Register <CargoWasAssignedToRouteEvent>(x =>
            {
                // New itinerary should satisfy new route
                Assert.AreEqual(RoutingStatus.Routed, x.Delivery.RoutingStatus);
                Assert.IsTrue(x.Delivery.IsMisdirected);
            }))
            {
                BookingService.AssignCargoToRoute(trackingId, newItinerary);
            }

            // -- Cargo has been rerouted, shipping continues --


            // Load in Tokyo
            using (DomainEvents.Register <CargoWasHandledEvent>(x =>
            {
                // Check current state - should be ok
                Assert.AreEqual(HONGKONG, x.Delivery.LastKnownLocation);
                Assert.AreEqual(TransportStatus.OnboardCarrier, x.Delivery.TransportStatus);
                Assert.IsFalse(x.Delivery.IsMisdirected);
                Assert.AreEqual(new HandlingActivity(HandlingEventType.Unload, HAMBURG), x.Delivery.NextExpectedActivity);
            }))
            {
                HandlingEventService.RegisterHandlingEvent(new DateTime(2009, 3, 8), trackingId, HONGKONG.UnLocode,
                                                           HandlingEventType.Load);
            }

            // Unload in Hamburg
            using (DomainEvents.Register <CargoWasHandledEvent>(x =>
            {
                // Check current state - should be ok
                Assert.AreEqual(HAMBURG, x.Delivery.LastKnownLocation);
                Assert.AreEqual(TransportStatus.InPort, x.Delivery.TransportStatus);
                Assert.IsFalse(x.Delivery.IsMisdirected);
                Assert.AreEqual(new HandlingActivity(HandlingEventType.Load, HAMBURG), x.Delivery.NextExpectedActivity);
            }))
            {
                HandlingEventService.RegisterHandlingEvent(new DateTime(2009, 3, 12), trackingId, HAMBURG.UnLocode,
                                                           HandlingEventType.Unload);
            }

            // Load in Hamburg
            using (DomainEvents.Register <CargoWasHandledEvent>(x =>
            {
                // Check current state - should be ok
                Assert.AreEqual(HAMBURG, x.Delivery.LastKnownLocation);
                Assert.AreEqual(TransportStatus.OnboardCarrier, x.Delivery.TransportStatus);
                Assert.IsFalse(x.Delivery.IsMisdirected);
                Assert.AreEqual(new HandlingActivity(HandlingEventType.Unload, GOETEBORG), x.Delivery.NextExpectedActivity);
            }))
            {
                HandlingEventService.RegisterHandlingEvent(new DateTime(2009, 3, 14), trackingId, HAMBURG.UnLocode,
                                                           HandlingEventType.Load);
            }

            // Unload in Stockholm
            using (DomainEvents.Register <CargoWasHandledEvent>(x =>
            {
                // Check current state - should be ok
                Assert.AreEqual(GOETEBORG, x.Delivery.LastKnownLocation);
                Assert.AreEqual(TransportStatus.InPort, x.Delivery.TransportStatus);
                Assert.IsFalse(x.Delivery.IsMisdirected);
                Assert.AreEqual(new HandlingActivity(HandlingEventType.Claim, GOETEBORG), x.Delivery.NextExpectedActivity);
            }))
            {
                HandlingEventService.RegisterHandlingEvent(new DateTime(2009, 3, 15), trackingId, GOETEBORG.UnLocode,
                                                           HandlingEventType.Unload);
            }


            // Finally, cargo is claimed in Stockholm. This ends the cargo lifecycle from our perspective.
            using (DomainEvents.Register <CargoWasHandledEvent>(x =>
            {
                // Check current state - should be ok
                Assert.AreEqual(GOETEBORG, x.Delivery.LastKnownLocation);
                Assert.AreEqual(TransportStatus.Claimed, x.Delivery.TransportStatus);
                Assert.IsFalse(x.Delivery.IsMisdirected);
                Assert.IsNull(x.Delivery.NextExpectedActivity);
            }))
            {
                HandlingEventService.RegisterHandlingEvent(new DateTime(2009, 3, 16), trackingId, GOETEBORG.UnLocode,
                                                           HandlingEventType.Claim);
            }
        }
Exemplo n.º 9
0
 public EmployeeRegisteredHandler(IEmployeeRepository employeeRepository)
 {
     _employeeRepository = employeeRepository;
     DomainEvents.Register <EmployeeRegisteredEvent>(EmployeeAdded);
     DomainEvents.Register <EmployeeServerValidatedEvent>(EmployeeServerValidated);
 }
Exemplo n.º 10
0
 void OnEnable( )
 {
     DomainEvents.Register <OnStageChange> (OnStageChange);
 }
 public EmployeeRegisteredHandler(IConsultantRepository consultantRepository)
 {
     _consultantRepository = consultantRepository;
     DomainEvents.Register <ConsultantAddedEvent>(ConsultantAdded);
     DomainEvents.Register <ConsultantServerValidatedEvent>(ConsultantServerValidated);
 }
Exemplo n.º 12
0
 protected override void OnLoad(System.EventArgs e)
 {
     base.OnLoad(e);
     DomainEvents.Register <CallStatusChanged>(changed => SetImagesFor(changed.CallStatus));
 }
Exemplo n.º 13
0
 public MakeBookingInvalidatedHandler(ITimeAllocationRepository timeAllocationRepository)
 {
     _timeAllocationRepository = timeAllocationRepository;
     DomainEvents.Register <TimeAllocationInvalidatedEvent>(TimeAllocationInvalidated);
 }
Exemplo n.º 14
0
 protected virtual void OnEnable( )
 {
     DomainEvents.Register <OnStateChanged> (HandleStateChanged);
 }
Exemplo n.º 15
0
 void OnEnable()
 {
     DomainEvents.Register <OnVFXPlay>(HandleVFXPlay);
     DomainEvents.Register <OnPlayerVFXPlay>(HandlePlayerVFXPlay);
 }
Exemplo n.º 16
0
 void OnEnable()
 {
     DomainEvents.Register <OnNodeEliminate>(HandleNodeEliminate);
     DomainEvents.Register <OnPlayerDead>(HandlePlayerDead);
     DomainEvents.Register <OnEnemyDead>(HandleEnemyDead);
 }
Exemplo n.º 17
0
 void OnEnable() => DomainEvents.Register <OnEnemyBeAttacked>(HandleEnemyBeAttacked);
Exemplo n.º 18
0
 public ActionState(GameController controller) : base(controller)
 {
     timer = new ScaledTimer();
     DomainEvents.Register <OnNodeDragEnd>(HandleNodeDragEnd);
 }
 public TwitchSettings()
 {
     DomainEvents.Register <AccessTokenReceived>(ReceivedAccessToken);
 }
Exemplo n.º 20
0
 void OnEnable()
 {
     DomainEvents.Register <OnGameStateChange>(HandleGameStateChange);
     DomainEvents.Register <OnNodeDragBegin>(HandleNodeDragBegin);
     DomainEvents.Register <OnNodeDragEnd>(HandleNodeDragEnd);
 }
Exemplo n.º 21
0
 public RoutineViewModel()
 {
     DomainEvents.Register <ILogoRoutineEvent>(Handle);
 }
Exemplo n.º 22
0
 public Project()
 {
     DomainEvents.Register <TaskCompletedEvent>(HandleTaskCompleted);
     DomainEvents.Register <TaskHoursUpdatedEvent>(HandleTaskHoursUpdated);
 }
Exemplo n.º 23
0
 public MappingsSourceViewModel()
 {
     Mappings = new MappingsCollection();
     DomainEvents.Register <MappingViewSelected>(HandleViewSelected);
 }
Exemplo n.º 24
0
 public SampleClient(Customer customer)
 {
     _customer = customer;
     DomainEvents.Register <CustomerNameUpdatedEvent>(CustomerOnNameChanged);
 }