/Framework/src/Ncqrs.Tests/Eventing/Sourcing/Mapping/InvalidEventHandlerMappingExceptionTests.cs
C# | 54 lines | 42 code | 12 blank | 0 comment | 0 complexity | 63a0ac310ad7905f3b3cfb69431307dd MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0
- using System;
- using System.IO;
- using System.Runtime.Serialization.Formatters.Binary;
- using FluentAssertions;
- using Ncqrs.Eventing.Sourcing.Mapping;
- using Xunit;
-
- namespace Ncqrs.Tests.Eventing.Sourcing.Mapping
- {
-
- public class InvalidEventHandlerMappingExceptionTests
- {
- [Fact]
- public void Constructing_an_instance_should_initialize_the_message()
- {
- String message = "Hello world";
-
- var target = new InvalidEventHandlerMappingException(message);
-
- target.Message.Should().Be(message);
- }
-
- [Fact]
- public void Constructing_an_instance_should_initialize_the_inner_exception()
- {
- String aMessage = "Hello world";
- var theInnerException = new Exception();
-
- var target = new InvalidEventHandlerMappingException(aMessage, theInnerException);
-
- target.InnerException.Should().Be(theInnerException);
- }
-
- [Fact]
- public void It_should_be_serializable()
- {
- var aMessage = "Hello world";
-
- var theException = new InvalidEventHandlerMappingException(aMessage);
- InvalidEventHandlerMappingException deserializedException = null;
-
- using (var buffer = new MemoryStream())
- {
- var formatter = new BinaryFormatter();
- formatter.Serialize(buffer, theException);
-
- buffer.Seek(0, SeekOrigin.Begin);
- deserializedException = (InvalidEventHandlerMappingException)formatter.Deserialize(buffer);
- }
-
- deserializedException.Should().NotBeNull();
- }
- }
- }