Ejemplo n.º 1
0
        public bool Equals(INotification <T> x, INotification <T> y)
        {
            if (x == null && y == null)
            {
                return(true);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            if (x.Kind != y.Kind)
            {
                return(false);
            }
            if (x.HasPredicate)
            {
                return(x.Equals(y));
            }
            else if (y.HasPredicate)
            {
                return(y.Equals(x));
            }
            else
            {
                return(x.Kind switch
                {
                    Protocol.NotificationKind.OnCompleted => x.Equals(y),
                    Protocol.NotificationKind.OnError => x.Equals(y),
                    Protocol.NotificationKind.OnNext => x.HasValue && y.HasValue && _valueComparer.Equals(x.Value, y.Value),
                    _ => throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unexpected notification kind '{0}'.", x.Kind)),
                });