test exception code complet
continuous-integration/drone/push Build is failing Details

master
Céleste BARBOSA 11 months ago
parent 33fea210d0
commit 34070bc5d8

@ -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<CodeCompletException>(jsonString);
Assert.NotNull(exceptionSerialisee);
Assert.Equal(exception.Message, exceptionSerialisee.Message);
}
}
}

Loading…
Cancel
Save