public void TestConstructor_RpcError_MesssagePackObject_DetailIsNil_AsIs() { var error = RpcError.MessageRefusedError; var detail = MessagePackObject.Nil; var target = new RpcErrorMessage( error, detail ); Assert.That( target.Error, Is.EqualTo( error ) ); Assert.That( target.Detail, Is.EqualTo( detail ) ); Assert.That( target.IsSuccess, Is.False ); }
public void TestConstructor_RpcError_MesssagePackObject_DetailIsNil_AsIs() { var error = RpcError.MessageRefusedError; var detail = MessagePackObject.Nil; var target = new RpcErrorMessage(error, detail); Assert.That(target.Error, Is.EqualTo(error)); Assert.That(target.Detail, Is.EqualTo(detail)); Assert.That(target.IsSuccess, Is.False); }
public void TestToString_ContainsErrorAndMessageAndDebug() { var message = Guid.NewGuid().ToString(); var debugInformation = Guid.NewGuid().ToString(); var target = new RpcErrorMessage(RpcError.MessageRefusedError, CreateDetail(message, debugInformation)); var result = target.ToString(); Assert.That(result, Is.StringContaining(message).And.StringContaining(debugInformation).And.StringContaining(target.Error.Identifier)); }
public void TestConstructor_RpcErrorStringString_MessageIsNull_NotContainedInDictionary() { var error = RpcError.MessageRefusedError; var message = default( string ); var debugInformation = Guid.NewGuid().ToString(); var target = new RpcErrorMessage( error, message, debugInformation ); Assert.That( target.Error, Is.EqualTo( error ) ); Assert.That( target.Detail.AsDictionary().ContainsKey( RpcException.MessageKeyUtf8 ), Is.False ); Assert.That( target.Detail.AsDictionary()[ RpcException.DebugInformationKeyUtf8 ].Equals( debugInformation ) ); Assert.That( target.IsSuccess, Is.False ); }
public void TestConstructor_RpcErrorStringString_DebugIsNull_NotContainedInDictionary() { var error = RpcError.MessageRefusedError; var message = Guid.NewGuid().ToString(); var debugInformation = default(string); var target = new RpcErrorMessage(error, message, debugInformation); Assert.That(target.Error, Is.EqualTo(error)); Assert.That(target.Detail.AsDictionary()[RpcException.MessageKeyUtf8].Equals(message)); Assert.That(target.Detail.AsDictionary().ContainsKey(RpcException.DebugInformationKeyUtf8), Is.False); Assert.That(target.IsSuccess, Is.False); }
public void TestEquals_DifferenceError_SameDetail_False() { var left = new RpcErrorMessage(RpcError.MessageTooLargeError, CreateDetail("Message", "Debug")); var right = new RpcErrorMessage(RpcError.MessageRefusedError, CreateDetail("Message", "Debug")); Assert.That(left.Equals(right), Is.False); Assert.That(right.Equals(left), Is.False); Assert.That(left == right, Is.False); Assert.That(right == left, Is.False); Assert.That(left != right, Is.True); Assert.That(right != left, Is.True); }
public void TestToException_RpcErrorMessagePackObject_NonDictionaryMesssagePackObject_Ignored() { var error = RpcError.MessageRefusedError; var detail = "ABC"; var target = new RpcErrorMessage(error, detail); var result = target.ToException(); Assert.That(result.RpcError, Is.EqualTo(error)); Assert.That(result.Message, Is.EqualTo(result.RpcError.DefaultMessageInvariant)); Assert.That(result.DebugInformation, Is.Not.Null.And.Empty); }
public void TestEquals_SameError_NilDetail_False() { var left = new RpcErrorMessage(RpcError.MessageRefusedError, CreateDetail("Message", "Debug")); var right = new RpcErrorMessage(RpcError.MessageRefusedError, MessagePackObject.Nil); Assert.That(left.Equals(right), Is.False); Assert.That(right.Equals(left), Is.False); Assert.That(left == right, Is.False); Assert.That(right == left, Is.False); Assert.That(left != right, Is.True); Assert.That(right != left, Is.True); }
public void TestToException_RpcErrorStringString_NotNull_AsIs() { var error = RpcError.MessageRefusedError; var message = Guid.NewGuid().ToString(); var debugInformation = Guid.NewGuid().ToString(); var target = new RpcErrorMessage(error, message, debugInformation); var result = target.ToException(); Assert.That(target.Error, Is.EqualTo(error)); Assert.That(target.Detail.AsDictionary()[RpcException.MessageKeyUtf8].Equals(message)); Assert.That(target.Detail.AsDictionary()[RpcException.DebugInformationKeyUtf8].Equals(debugInformation)); Assert.That(target.IsSuccess, Is.False); }
public void TestToException_RpcErrorMessagePackObject_DictionaryMesssagePackObject_AsIs() { var error = RpcError.MessageRefusedError; var message = Guid.NewGuid().ToString(); var debugInformation = Guid.NewGuid().ToString(); var detail = new MessagePackObjectDictionary() { { RpcException.MessageKeyUtf8, message }, { RpcException.DebugInformationKeyUtf8, debugInformation } }; var target = new RpcErrorMessage(error, new MessagePackObject(detail)); var result = target.ToException(); Assert.That(result.RpcError, Is.EqualTo(error)); Assert.That(result.Message, Is.EqualTo(message)); Assert.That(result.DebugInformation, Is.EqualTo(debugInformation)); }
public void TestToString_ContainsErrorAndMessageAndDebug() { var message = Guid.NewGuid().ToString(); var debugInformation = Guid.NewGuid().ToString(); var target = new RpcErrorMessage( RpcError.MessageRefusedError, CreateDetail( message, debugInformation ) ); var result = target.ToString(); Assert.That( result, Is.StringContaining( message ).And.StringContaining( debugInformation ).And.StringContaining( target.Error.Identifier ) ); }
public void TestGetHashCode_AtLeastSuccess() { var target = new RpcErrorMessage( RpcError.MessageRefusedError, CreateDetail( "Message", "Debug" ) ); target.GetHashCode(); }
public void TestEquals_OtherType_False() { var left = new RpcErrorMessage( RpcError.MessageRefusedError, CreateDetail( "Message", "Debug" ) ); Assert.That( left.Equals( "ABC" ), Is.False ); }
public void TestEquals_SameError_NilDetail_False() { var left = new RpcErrorMessage( RpcError.MessageRefusedError, CreateDetail( "Message", "Debug" ) ); var right = new RpcErrorMessage( RpcError.MessageRefusedError, MessagePackObject.Nil ); Assert.That( left.Equals( right ), Is.False ); Assert.That( right.Equals( left ), Is.False ); Assert.That( left == right, Is.False ); Assert.That( right == left, Is.False ); Assert.That( left != right, Is.True ); Assert.That( right != left, Is.True ); }
public void TestEquals_DifferenceError_SameDetail_False() { var left = new RpcErrorMessage( RpcError.MessageTooLargeError, CreateDetail( "Message", "Debug" ) ); var right = new RpcErrorMessage( RpcError.MessageRefusedError, CreateDetail( "Message", "Debug" ) ); Assert.That( left.Equals( right ), Is.False ); Assert.That( right.Equals( left ), Is.False ); Assert.That( left == right, Is.False ); Assert.That( right == left, Is.False ); Assert.That( left != right, Is.True ); Assert.That( right != left, Is.True ); }
public void TestToException_RpcErrorStringString_NotNull_AsIs() { var error = RpcError.MessageRefusedError; var message = Guid.NewGuid().ToString(); var debugInformation = Guid.NewGuid().ToString(); var target = new RpcErrorMessage( error, message, debugInformation ); var result = target.ToException(); Assert.That( target.Error, Is.EqualTo( error ) ); Assert.That( target.Detail.AsDictionary()[ RpcException.MessageKeyUtf8 ].Equals( message ) ); Assert.That( target.Detail.AsDictionary()[ RpcException.DebugInformationKeyUtf8 ].Equals( debugInformation ) ); Assert.That( target.IsSuccess, Is.False ); }
public void TestGetHashCode_AtLeastSuccess() { var target = new RpcErrorMessage(RpcError.MessageRefusedError, CreateDetail("Message", "Debug")); target.GetHashCode(); }
public void TestConstructor_RpcErrorStringString_ErrorIsNull() { var target = new RpcErrorMessage( null, "A", "B" ); }
public void TestConstructor_RpcErrorStringString_ErrorIsNull() { var target = new RpcErrorMessage(null, "A", "B"); }
public void TestConstructor_RpcError_MesssagePackObject_RpcErrorIsNull() { var target = new RpcErrorMessage(null, "ABC"); }
public void TestConstructor_RpcError_MesssagePackObject_RpcErrorIsNull() { var target = new RpcErrorMessage( null, "ABC" ); }
public void TestToException_RpcErrorMessagePackObject_DictionaryMesssagePackObject_AsIs() { var error = RpcError.MessageRefusedError; var message = Guid.NewGuid().ToString(); var debugInformation = Guid.NewGuid().ToString(); var detail = new MessagePackObjectDictionary() { { RpcException.MessageKeyUtf8, message }, { RpcException.DebugInformationKeyUtf8, debugInformation } }; var target = new RpcErrorMessage( error, new MessagePackObject( detail ) ); var result = target.ToException(); Assert.That( result.RpcError, Is.EqualTo( error ) ); Assert.That( result.Message, Is.EqualTo( message ) ); Assert.That( result.DebugInformation, Is.EqualTo( debugInformation ) ); }
public void TestToException_RpcErrorMessagePackObject_NonDictionaryMesssagePackObject_Ignored() { var error = RpcError.MessageRefusedError; var detail = "ABC"; var target = new RpcErrorMessage( error, detail ); var result = target.ToException(); Assert.That( result.RpcError, Is.EqualTo( error ) ); Assert.That( result.Message, Is.EqualTo( result.RpcError.DefaultMessageInvariant ) ); Assert.That( result.DebugInformation, Is.Not.Null.And.Empty ); }
public void TestEquals_OtherType_False() { var left = new RpcErrorMessage(RpcError.MessageRefusedError, CreateDetail("Message", "Debug")); Assert.That(left.Equals("ABC"), Is.False); }
/// <summary> /// Complete this invocation as error. /// </summary> /// <param name="error"> /// Occurred RPC error. /// </param> /// <param name="completedSynchronously"> /// When operation is completed same thread as initiater then true. /// </param> public void HandleError( RpcErrorMessage error, bool completedSynchronously ) { this.OnError( RpcException.FromRpcError( error ), completedSynchronously ); }
/// <summary> /// Create <see cref="RpcException"/> for specified serialization error. /// </summary> /// <param name="serializationError">Serialization error.</param> /// <returns> /// <see cref="RpcException"/> for specified serialization error. /// </returns> internal static RpcException FromRpcError( RpcErrorMessage serializationError ) { return serializationError.Error.ToException( serializationError.Detail ); }