diff --git a/Sources/UnitTesting/CodeCompletExceptionUT.cs b/Sources/UnitTesting/CodeCompletExceptionUT.cs index 06ebf97..865a9f6 100644 --- a/Sources/UnitTesting/CodeCompletExceptionUT.cs +++ b/Sources/UnitTesting/CodeCompletExceptionUT.cs @@ -1,4 +1,7 @@ using CoreLibrary.Exceptions; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text.Json; using Xunit; namespace UnitTesting @@ -22,7 +25,7 @@ namespace UnitTesting { throw new CodeCompletException(message); } - catch(CodeCompletException e) + catch (CodeCompletException e) { Assert.Equal(message, e.Message); } @@ -50,5 +53,17 @@ namespace UnitTesting } } + [Fact] + public void ExceptionSerialisation() + { + CodeCompletException exception = new CodeCompletException(); + + string jsonString = JsonSerializer.Serialize(exception); + CodeCompletException? exceptionSerialisee = + JsonSerializer.Deserialize(jsonString); + + Assert.NotNull(exceptionSerialisee); + Assert.Equal(exception.Message, exceptionSerialisee.Message); + } } }