tests unitaires sur les exceptions
continuous-integration/drone/push Build is passing Details

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

@ -0,0 +1,54 @@
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class CodeCompletExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<CodeCompletException>(() => throw new CodeCompletException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<CodeCompletException>(() => throw new CodeCompletException(message));
try
{
throw new CodeCompletException(message);
}
catch(CodeCompletException 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<CodeCompletException>(() => throw new CodeCompletException(message, parent));
try
{
throw new CodeCompletException(message, parent);
}
catch (CodeCompletException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}

@ -0,0 +1,54 @@
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class CodeIncompletExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<CodeIncompletException>(() => throw new CodeIncompletException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<CodeIncompletException>(() => throw new CodeIncompletException(message));
try
{
throw new CodeIncompletException(message);
}
catch(CodeIncompletException 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<CodeIncompletException>(() => throw new CodeIncompletException(message, parent));
try
{
throw new CodeIncompletException(message, parent);
}
catch (CodeIncompletException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}

@ -0,0 +1,71 @@
using CoreLibrary.Exceptions;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
using Xunit;
namespace UnitTesting
{
public class CodeInvalideExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<CodeInvalideException>(() => throw new CodeInvalideException());
}
[Fact]
public void ExceptionAttributs()
{
Assert.ThrowsAsync<CodeInvalideException>(() => throw new CodeInvalideException(3, 4));
try
{
throw new CodeInvalideException(3, 4);
}
catch (CodeInvalideException e)
{
Assert.Contains("3", e.Message);
Assert.Contains("4", e.Message);
}
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<CodeInvalideException>(() => throw new CodeInvalideException(message));
try
{
throw new CodeInvalideException(message);
}
catch(CodeInvalideException 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<CodeInvalideException>(() => throw new CodeInvalideException(message, parent));
try
{
throw new CodeInvalideException(message, parent);
}
catch (CodeInvalideException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}

@ -0,0 +1,54 @@
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class CodeVideExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<CodeVideException>(() => throw new CodeVideException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<CodeVideException>(() => throw new CodeVideException(message));
try
{
throw new CodeVideException(message);
}
catch(CodeVideException 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<CodeVideException>(() => throw new CodeVideException(message, parent));
try
{
throw new CodeVideException(message, parent);
}
catch (CodeVideException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}

@ -0,0 +1,70 @@
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class IndiceCodeExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<IndiceCodeException>(() => throw new IndiceCodeException());
}
[Fact]
public void ExceptionAttributs()
{
Assert.ThrowsAsync<IndiceCodeException>(() => throw new IndiceCodeException(5, 3));
try
{
throw new IndiceCodeException(5, 3);
}
catch (IndiceCodeException e)
{
Assert.Contains("5", e.Message);
Assert.Contains("3", e.Message);
}
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<IndiceCodeException>(() => throw new IndiceCodeException(message));
try
{
throw new IndiceCodeException(message);
}
catch(IndiceCodeException 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<IndiceCodeException>(() => throw new IndiceCodeException(message, parent));
try
{
throw new IndiceCodeException(message, parent);
}
catch (IndiceCodeException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}

@ -0,0 +1,54 @@
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class PartieNonCommenceeExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<PartieNonCommenceeException>(() => throw new PartieNonCommenceeException());
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<PartieNonCommenceeException>(() => throw new PartieNonCommenceeException(message));
try
{
throw new PartieNonCommenceeException(message);
}
catch(PartieNonCommenceeException 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<PartieNonCommenceeException>(() => throw new PartieNonCommenceeException(message, parent));
try
{
throw new PartieNonCommenceeException(message, parent);
}
catch (PartieNonCommenceeException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}

@ -0,0 +1,69 @@
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class TailleCodeExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<TailleCodeException>(() => throw new TailleCodeException());
}
[Fact]
public void ExceptionAttributs()
{
Assert.ThrowsAsync<TailleCodeException>(() => throw new TailleCodeException(-3));
try
{
throw new TailleCodeException(-3);
}
catch (TailleCodeException e)
{
Assert.Contains("-3", e.Message);
}
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<TailleCodeException>(() => throw new TailleCodeException(message));
try
{
throw new TailleCodeException(message);
}
catch(TailleCodeException 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<TailleCodeException>(() => throw new TailleCodeException(message, parent));
try
{
throw new TailleCodeException(message, parent);
}
catch (TailleCodeException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}

@ -0,0 +1,69 @@
using CoreLibrary.Exceptions;
using Xunit;
namespace UnitTesting
{
public class TailleGrilleExceptionUT
{
[Fact]
public void ExceptionDefaut()
{
Assert.ThrowsAsync<TailleGrilleException>(() => throw new TailleGrilleException());
}
[Fact]
public void ExceptionAttributs()
{
Assert.ThrowsAsync<TailleGrilleException>(() => throw new TailleGrilleException(0));
try
{
throw new TailleCodeException(0);
}
catch (TailleCodeException e)
{
Assert.Contains("0", e.Message);
}
}
[Fact]
public void ExceptionMessage()
{
string message = "Mon super gros problème.";
Assert.ThrowsAsync<TailleGrilleException>(() => throw new TailleGrilleException(message));
try
{
throw new TailleGrilleException(message);
}
catch(TailleGrilleException 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<TailleGrilleException>(() => throw new TailleGrilleException(message, parent));
try
{
throw new TailleGrilleException(message, parent);
}
catch (TailleGrilleException e)
{
Assert.Equal(message, e.Message);
Assert.NotNull(e.InnerException);
Assert.IsType<InvalidOperationException>(e.InnerException);
Assert.Equal(message2, e.InnerException.Message);
}
}
}
}
Loading…
Cancel
Save