tentative tests unitaires sur une exception
continuous-integration/drone/push Build is passing Details

master
Céleste BARBOSA 12 months ago
parent e999c3f547
commit 6fe01f6698

@ -1,5 +1,4 @@
using CoreLibrary;
using CoreLibrary.Events;
using CoreLibrary.Events;
using Xunit;
namespace UnitTesting

@ -0,0 +1,54 @@
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class GrilleCompleteExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<GrilleCompleteException>(() => throw new GrilleCompleteException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<GrilleCompleteException>(() => throw new GrilleCompleteException(message));
try
{
throw new GrilleCompleteException(message);
}
catch(GrilleCompleteException e)
{
Assert.Equal(message, e.Message);
}
}
[Fact]
public void ExceptionMessageEtException()
{
string message = "Mon super gros problème.";
string message2 = "Pas de chance...";
InvalidOperationException parent = new InvalidOperationException(message2);
Assert.ThrowsAsync<GrilleCompleteException>(() => throw new GrilleCompleteException(message, parent));
try
{
throw new GrilleCompleteException(message, parent);
}
catch (GrilleCompleteException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}
Loading…
Cancel
Save