|
@@ -19,18 +19,19 @@ namespace Microsoft.Reactive.Testing
|
|
|
#endif
|
|
#endif
|
|
|
public readonly struct Recorded<T> : IEquatable<Recorded<T>>
|
|
public readonly struct Recorded<T> : IEquatable<Recorded<T>>
|
|
|
{
|
|
{
|
|
|
|
|
+ // NB: Keep these fields for compat with serialized state.
|
|
|
private readonly long _time;
|
|
private readonly long _time;
|
|
|
private readonly T _value;
|
|
private readonly T _value;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the virtual time the value was produced on.
|
|
/// Gets the virtual time the value was produced on.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public long Time { get { return _time; } }
|
|
|
|
|
|
|
+ public long Time => _time;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the recorded value.
|
|
/// Gets the recorded value.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public T Value { get { return _value; } }
|
|
|
|
|
|
|
+ public T Value => _value;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Creates a new object recording the production of the specified value at the given virtual time.
|
|
/// Creates a new object recording the production of the specified value at the given virtual time.
|
|
@@ -48,10 +49,7 @@ namespace Microsoft.Reactive.Testing
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="other">Recorded object to check for equality.</param>
|
|
/// <param name="other">Recorded object to check for equality.</param>
|
|
|
/// <returns>true if both objects are equal; false otherwise.</returns>
|
|
/// <returns>true if both objects are equal; false otherwise.</returns>
|
|
|
- public bool Equals(Recorded<T> other)
|
|
|
|
|
- {
|
|
|
|
|
- return Time == other.Time && EqualityComparer<T>.Default.Equals(Value, other.Value);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public bool Equals(Recorded<T> other) => Time == other.Time && EqualityComparer<T>.Default.Equals(Value, other.Value);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Determines whether the two specified <see cref="Recorded{T}"/> values have the same Time and Value.
|
|
/// Determines whether the two specified <see cref="Recorded{T}"/> values have the same Time and Value.
|
|
@@ -59,10 +57,7 @@ namespace Microsoft.Reactive.Testing
|
|
|
/// <param name="left">The first <see cref="Recorded{T}"/> value to compare.</param>
|
|
/// <param name="left">The first <see cref="Recorded{T}"/> value to compare.</param>
|
|
|
/// <param name="right">The second <see cref="Recorded{T}"/> value to compare.</param>
|
|
/// <param name="right">The second <see cref="Recorded{T}"/> value to compare.</param>
|
|
|
/// <returns>true if the first <see cref="Recorded{T}"/> value has the same Time and Value as the second <see cref="Recorded{T}"/> value; otherwise, false.</returns>
|
|
/// <returns>true if the first <see cref="Recorded{T}"/> value has the same Time and Value as the second <see cref="Recorded{T}"/> value; otherwise, false.</returns>
|
|
|
- public static bool operator ==(Recorded<T> left, Recorded<T> right)
|
|
|
|
|
- {
|
|
|
|
|
- return left.Equals(right);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public static bool operator ==(Recorded<T> left, Recorded<T> right) => left.Equals(right);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Determines whether the two specified <see cref="Recorded{T}"/> values don't have the same Time and Value.
|
|
/// Determines whether the two specified <see cref="Recorded{T}"/> values don't have the same Time and Value.
|
|
@@ -70,25 +65,14 @@ namespace Microsoft.Reactive.Testing
|
|
|
/// <param name="left">The first <see cref="Recorded{T}"/> value to compare.</param>
|
|
/// <param name="left">The first <see cref="Recorded{T}"/> value to compare.</param>
|
|
|
/// <param name="right">The second <see cref="Recorded{T}"/> value to compare.</param>
|
|
/// <param name="right">The second <see cref="Recorded{T}"/> value to compare.</param>
|
|
|
/// <returns>true if the first <see cref="Recorded{T}"/> value has a different Time or Value as the second <see cref="Recorded{T}"/> value; otherwise, false.</returns>
|
|
/// <returns>true if the first <see cref="Recorded{T}"/> value has a different Time or Value as the second <see cref="Recorded{T}"/> value; otherwise, false.</returns>
|
|
|
- public static bool operator !=(Recorded<T> left, Recorded<T> right)
|
|
|
|
|
- {
|
|
|
|
|
- return !left.Equals(right);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public static bool operator !=(Recorded<T> left, Recorded<T> right) => !left.Equals(right);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Determines whether the specified System.Object is equal to the current <see cref="Recorded{T}"/> value.
|
|
/// Determines whether the specified System.Object is equal to the current <see cref="Recorded{T}"/> value.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="obj">The System.Object to compare with the current <see cref="Recorded{T}"/> value.</param>
|
|
/// <param name="obj">The System.Object to compare with the current <see cref="Recorded{T}"/> value.</param>
|
|
|
/// <returns>true if the specified System.Object is equal to the current <see cref="Recorded{T}"/> value; otherwise, false.</returns>
|
|
/// <returns>true if the specified System.Object is equal to the current <see cref="Recorded{T}"/> value; otherwise, false.</returns>
|
|
|
- public override bool Equals(object obj)
|
|
|
|
|
- {
|
|
|
|
|
- if (obj is Recorded<T>)
|
|
|
|
|
- {
|
|
|
|
|
- return Equals((Recorded<T>)obj);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public override bool Equals(object obj) => obj is Recorded<T> && Equals((Recorded<T>)obj);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Returns the hash code for the current <see cref="Recorded{T}"/> value.
|
|
/// Returns the hash code for the current <see cref="Recorded{T}"/> value.
|
|
@@ -96,6 +80,7 @@ namespace Microsoft.Reactive.Testing
|
|
|
/// <returns>A hash code for the current <see cref="Recorded{T}"/> value.</returns>
|
|
/// <returns>A hash code for the current <see cref="Recorded{T}"/> value.</returns>
|
|
|
public override int GetHashCode()
|
|
public override int GetHashCode()
|
|
|
{
|
|
{
|
|
|
|
|
+ // TODO: Use proper hash code combiner.
|
|
|
return Time.GetHashCode() + EqualityComparer<T>.Default.GetHashCode(Value);
|
|
return Time.GetHashCode() + EqualityComparer<T>.Default.GetHashCode(Value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -103,9 +88,6 @@ namespace Microsoft.Reactive.Testing
|
|
|
/// Returns a string representation of the current <see cref="Recorded{T}"/> value.
|
|
/// Returns a string representation of the current <see cref="Recorded{T}"/> value.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <returns>String representation of the current <see cref="Recorded{T}"/> value.</returns>
|
|
/// <returns>String representation of the current <see cref="Recorded{T}"/> value.</returns>
|
|
|
- public override string ToString()
|
|
|
|
|
- {
|
|
|
|
|
- return Value.ToString() + "@" + Time.ToString(CultureInfo.CurrentCulture);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public override string ToString() => Value.ToString() + "@" + Time.ToString(CultureInfo.CurrentCulture);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|