private static void TestInEquality(ActorId x, ActorId y)
        {
            Assert.False(
                (x == y),
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Verify {0} == {1} is false",
                    ToStringWithKind(x),
                    ToStringWithKind(y)));

            Assert.True(
                (x != y),
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Verify {0} != {1} is true",
                    ToStringWithKind(x),
                    ToStringWithKind(y)));

            Assert.False(
                x.Equals(y),
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Verify {0} Equals {1} is false",
                    ToStringWithKind(x),
                    ToStringWithKind(y)));

            object z = y as object;

            Assert.False(
                x.Equals(z),
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Verify {0} Equals {1} as object is false",
                    ToStringWithKind(x),
                    z.ToString()));

            Assert.False(
                x.CompareTo(y) == 0,
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Verify {0} CompareTo {1} is not zero",
                    ToStringWithKind(x),
                    ToStringWithKind(y)));
        }
        public void TestNullEquality()
        {
            ActorId x = null;
            ActorId y = new ActorId(1);

            Assert.False((x == y), "Verify null == ActorId(1) is false");
            Assert.True((x != y), "Verify null != ActorId(1) is false");

            Assert.False(y.Equals(x), "Verify ActorId(1).Equals(null) is false");
            Assert.True(y.CompareTo(x) != 0, "Verify ActorId(1).CompareTo(null) is not zero");
        }
        /// <inheritdoc/>
        internal override void SendEvent(ActorId targetId, Event e, Actor sender, Guid opGroupId, SendOptions options)
        {
            this.Assert(sender is null || this.Instance.Id.Equals(sender.Id),
                        string.Format("Only {0} can send an event during this test.", this.Instance.Id.ToString()));
            this.Assert(e != null, string.Format("{0} is sending a null event.", this.Instance.Id.ToString()));
            this.Assert(targetId != null, string.Format("{0} is sending event {1} to a null actor.", this.Instance.Id.ToString(), e.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 actor, 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.Instance.IsHalted)
            {
                this.LogWriter.LogSendEvent(targetId, sender?.Id.Name, sender?.Id.Type,
                                            (sender as StateMachine)?.CurrentStateName ?? string.Empty, e, opGroupId, isTargetHalted: true);
                return;
            }

            this.LogWriter.LogSendEvent(targetId, sender?.Id.Name, sender?.Id.Type,
                                        (sender as StateMachine)?.CurrentStateName ?? string.Empty, e, opGroupId, isTargetHalted: false);

            if (!targetId.Equals(this.Instance.Id))
            {
                // Drop all events sent to an actor other than the actor-under-test.
                return;
            }

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

            if (enqueueStatus == EnqueueStatus.EventHandlerNotRunning)
            {
                this.RunActorEventHandlerAsync(this.Instance, null, false);
            }
        }
Exemplo n.º 4
0
 public void Verify_Equals_By_ActorId(ActorId id1, ActorId id2, bool expectedValue)
 {
     Assert.Equal(expectedValue, id1.Equals(id2));
 }
Exemplo n.º 5
0
 private static bool IsMatch(ActorId id, ActorId actor)
 {
     return actor.Equals(id) ||
            (id.IsLocal && id.Name == actor.Name);
 }
 public override bool Equals(object obj)
 {
     return(obj is ActorDescriptor descriptor &&
            ActorId.Equals(descriptor.ActorId));
 }