PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Framework/src/Ncqrs.Tests/Eventing/Sourcing/Mapping/InvalidEventHandlerMappingExceptionTests.cs

http://github.com/ncqrs/ncqrs
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
  1. using System;
  2. using System.IO;
  3. using System.Runtime.Serialization.Formatters.Binary;
  4. using FluentAssertions;
  5. using Ncqrs.Eventing.Sourcing.Mapping;
  6. using Xunit;
  7. namespace Ncqrs.Tests.Eventing.Sourcing.Mapping
  8. {
  9. public class InvalidEventHandlerMappingExceptionTests
  10. {
  11. [Fact]
  12. public void Constructing_an_instance_should_initialize_the_message()
  13. {
  14. String message = "Hello world";
  15. var target = new InvalidEventHandlerMappingException(message);
  16. target.Message.Should().Be(message);
  17. }
  18. [Fact]
  19. public void Constructing_an_instance_should_initialize_the_inner_exception()
  20. {
  21. String aMessage = "Hello world";
  22. var theInnerException = new Exception();
  23. var target = new InvalidEventHandlerMappingException(aMessage, theInnerException);
  24. target.InnerException.Should().Be(theInnerException);
  25. }
  26. [Fact]
  27. public void It_should_be_serializable()
  28. {
  29. var aMessage = "Hello world";
  30. var theException = new InvalidEventHandlerMappingException(aMessage);
  31. InvalidEventHandlerMappingException deserializedException = null;
  32. using (var buffer = new MemoryStream())
  33. {
  34. var formatter = new BinaryFormatter();
  35. formatter.Serialize(buffer, theException);
  36. buffer.Seek(0, SeekOrigin.Begin);
  37. deserializedException = (InvalidEventHandlerMappingException)formatter.Deserialize(buffer);
  38. }
  39. deserializedException.Should().NotBeNull();
  40. }
  41. }
  42. }