PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Framework/src/Ncqrs.Tests/Domain/NoUnitOfWorkAvailableInThisContextExceptionTests.cs

http://github.com/ncqrs/ncqrs
C# | 52 lines | 41 code | 11 blank | 0 comment | 0 complexity | 5f395539600acbf9c0cb3b21edf72930 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.Domain;
  6. using Xunit;
  7. namespace Ncqrs.Tests.Domain
  8. {
  9. public class NoUnitOfWorkAvailableInThisContextExceptionTests
  10. {
  11. [Fact]
  12. public void Constructing_an_instance_should_initialize_the_message()
  13. {
  14. String message = "Hello world";
  15. var target = new NoUnitOfWorkAvailableInThisContextException(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 NoUnitOfWorkAvailableInThisContextException(aMessage, theInnerException);
  24. target.InnerException.Should().Be(theInnerException);
  25. }
  26. [Fact]
  27. public void It_should_be_serializable()
  28. {
  29. var theException = new NoUnitOfWorkAvailableInThisContextException();
  30. NoUnitOfWorkAvailableInThisContextException deserializedException = null;
  31. using (var buffer = new MemoryStream())
  32. {
  33. var formatter = new BinaryFormatter();
  34. formatter.Serialize(buffer, theException);
  35. buffer.Seek(0, SeekOrigin.Begin);
  36. deserializedException = (NoUnitOfWorkAvailableInThisContextException)formatter.Deserialize(buffer);
  37. }
  38. deserializedException.Should().NotBeNull();
  39. }
  40. }
  41. }