コード例 #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();
            }
        }
コード例 #2
0
 public BookingUpdatedHandler(ITimeAllocationRepository timeAllocationRepository)
 {
     _timeAllocationRepository = timeAllocationRepository;
     DomainEvents.Register <TimeAllocationUpdatedEvent>(TimeAllocationUpdated);
 }
コード例 #3
0
 public ExternalSpeaker()
 {
     DomainEvents.Register <DiskInsertedEvent>((e) => { TurnOn(); });
     DomainEvents.Register <DiskEjectedEvent>((e) => { TurnOff(); });
 }
コード例 #4
0
 void OnEnable( )
 {
     DomainEvents.Register <OnGameStarted> (OnGameStarted);
 }
コード例 #5
0
 public void TestRaiseShouldRaiseARegisteredEvent()
 {
     DomainEvents.Register <FakeDomainEvent>(p => { _wasHandled = true; });
     DomainEvents.Raise(_event);
     Assert.That(_wasHandled, Is.True);
 }
コード例 #6
0
 public void Initialize()
 {
     DomainEvents.Register <CallStatusChanged>(CallStatusChanged);
     busylightAdapter.TurnBlue();
 }
コード例 #7
0
 void OnEnable() => DomainEvents.Register <OnManaChanged>(HandleManaChanged);
コード例 #8
0
        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);
            }
        }
コード例 #9
0
 public EmployeeRegisteredHandler(IEmployeeRepository employeeRepository)
 {
     _employeeRepository = employeeRepository;
     DomainEvents.Register <EmployeeRegisteredEvent>(EmployeeAdded);
     DomainEvents.Register <EmployeeServerValidatedEvent>(EmployeeServerValidated);
 }
コード例 #10
0
 void OnEnable( )
 {
     DomainEvents.Register <OnStageChange> (OnStageChange);
 }
コード例 #11
0
 public EmployeeRegisteredHandler(IConsultantRepository consultantRepository)
 {
     _consultantRepository = consultantRepository;
     DomainEvents.Register <ConsultantAddedEvent>(ConsultantAdded);
     DomainEvents.Register <ConsultantServerValidatedEvent>(ConsultantServerValidated);
 }
コード例 #12
0
ファイル: CallStatusForm.cs プロジェクト: RossCode/SkypeLight
 protected override void OnLoad(System.EventArgs e)
 {
     base.OnLoad(e);
     DomainEvents.Register <CallStatusChanged>(changed => SetImagesFor(changed.CallStatus));
 }
コード例 #13
0
 public MakeBookingInvalidatedHandler(ITimeAllocationRepository timeAllocationRepository)
 {
     _timeAllocationRepository = timeAllocationRepository;
     DomainEvents.Register <TimeAllocationInvalidatedEvent>(TimeAllocationInvalidated);
 }
コード例 #14
0
ファイル: Character.cs プロジェクト: scream870102/Splash
 protected virtual void OnEnable( )
 {
     DomainEvents.Register <OnStateChanged> (HandleStateChanged);
 }
コード例 #15
0
 void OnEnable()
 {
     DomainEvents.Register <OnVFXPlay>(HandleVFXPlay);
     DomainEvents.Register <OnPlayerVFXPlay>(HandlePlayerVFXPlay);
 }
コード例 #16
0
 void OnEnable()
 {
     DomainEvents.Register <OnNodeEliminate>(HandleNodeEliminate);
     DomainEvents.Register <OnPlayerDead>(HandlePlayerDead);
     DomainEvents.Register <OnEnemyDead>(HandleEnemyDead);
 }
コード例 #17
0
ファイル: Enemy.cs プロジェクト: scream870102/ThreeMatchGame
 void OnEnable() => DomainEvents.Register <OnEnemyBeAttacked>(HandleEnemyBeAttacked);
コード例 #18
0
 public ActionState(GameController controller) : base(controller)
 {
     timer = new ScaledTimer();
     DomainEvents.Register <OnNodeDragEnd>(HandleNodeDragEnd);
 }
コード例 #19
0
 public TwitchSettings()
 {
     DomainEvents.Register <AccessTokenReceived>(ReceivedAccessToken);
 }
コード例 #20
0
 void OnEnable()
 {
     DomainEvents.Register <OnGameStateChange>(HandleGameStateChange);
     DomainEvents.Register <OnNodeDragBegin>(HandleNodeDragBegin);
     DomainEvents.Register <OnNodeDragEnd>(HandleNodeDragEnd);
 }
コード例 #21
0
ファイル: RoutineViewModel.cs プロジェクト: arlm/MhsLogo
 public RoutineViewModel()
 {
     DomainEvents.Register <ILogoRoutineEvent>(Handle);
 }
コード例 #22
0
 public Project()
 {
     DomainEvents.Register <TaskCompletedEvent>(HandleTaskCompleted);
     DomainEvents.Register <TaskHoursUpdatedEvent>(HandleTaskHoursUpdated);
 }
コード例 #23
0
 public MappingsSourceViewModel()
 {
     Mappings = new MappingsCollection();
     DomainEvents.Register <MappingViewSelected>(HandleViewSelected);
 }
コード例 #24
0
 public SampleClient(Customer customer)
 {
     _customer = customer;
     DomainEvents.Register <CustomerNameUpdatedEvent>(CustomerOnNameChanged);
 }