Ejemplo n.º 1
0
        /// <summary>
        /// Sends an asynchronous <see cref="Event"/> to a machine.
        /// </summary>
        internal override void SendEvent(MachineId target, Event e, AsyncMachine sender, Guid opGroupId, SendOptions options)
        {
            this.Assert(sender is null || this.Machine.Id.Equals(sender.Id),
                        string.Format("Only machine '{0}' can send an event during this test.", this.Machine.Id.ToString()));
            this.Assert(target != null, string.Format("Machine '{0}' is sending to a null machine.", this.Machine.Id.ToString()));
            this.Assert(e != null, string.Format("Machine '{0}' is sending a null event.", this.Machine.Id.ToString()));

            // The operation group id of this operation is set using the following precedence:
            // (1) To the specified send operation group id, if it is non-empty.
            // (2) To the operation group id of the sender machine, if it exists and is non-empty.
            // (3) To the empty operation group id.
            if (opGroupId == Guid.Empty && sender != null)
            {
                opGroupId = sender.OperationGroupId;
            }

            if (this.Machine.IsHalted)
            {
                this.LogWriter.OnSend(target, sender?.Id, (sender as Machine)?.CurrentStateName ?? string.Empty,
                                      e.GetType().FullName, opGroupId, isTargetHalted: true);
                return;
            }

            this.LogWriter.OnSend(target, sender?.Id, (sender as Machine)?.CurrentStateName ?? string.Empty,
                                  e.GetType().FullName, opGroupId, isTargetHalted: false);

            if (!target.Equals(this.Machine.Id))
            {
                // Drop all events sent to a machine other than the machine-under-test.
                return;
            }

            EnqueueStatus enqueueStatus = this.Machine.Enqueue(e, opGroupId, null);

            if (enqueueStatus == EnqueueStatus.EventHandlerNotRunning)
            {
                this.RunMachineEventHandler(this.Machine, null, false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type
 /// </summary>
 /// <returns>
 /// <c>true</c> if the current object is equal to the <paramref identifier="other"/> parameter; otherwise, <c>false</c>
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public bool Equals(Status <T> other)
 {
     return(MachineId.Equals(other.MachineId) && State.Equals(other.State));
 }