diff --git a/Sources/UnitTesting/CodeCompletExceptionUT.cs b/Sources/UnitTesting/CodeCompletExceptionUT.cs new file mode 100644 index 0000000..06ebf97 --- /dev/null +++ b/Sources/UnitTesting/CodeCompletExceptionUT.cs @@ -0,0 +1,54 @@ +using CoreLibrary.Exceptions; +using Xunit; + +namespace UnitTesting +{ + public class CodeCompletExceptionUT + { + [Fact] + public void ExceptionDefaut() + { + Assert.ThrowsAsync(() => throw new CodeCompletException()); + } + + [Fact] + public void ExceptionMessage() + { + string message = "Mon super gros problème."; + + Assert.ThrowsAsync(() => 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(() => 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(e.InnerException); + Assert.Equal(message2, e.InnerException.Message); + } + } + + } +} diff --git a/Sources/UnitTesting/CodeIncompletExceptionUT.cs b/Sources/UnitTesting/CodeIncompletExceptionUT.cs new file mode 100644 index 0000000..b6bed0f --- /dev/null +++ b/Sources/UnitTesting/CodeIncompletExceptionUT.cs @@ -0,0 +1,54 @@ +using CoreLibrary.Exceptions; +using Xunit; + +namespace UnitTesting +{ + public class CodeIncompletExceptionUT + { + [Fact] + public void ExceptionDefaut() + { + Assert.ThrowsAsync(() => throw new CodeIncompletException()); + } + + [Fact] + public void ExceptionMessage() + { + string message = "Mon super gros problème."; + + Assert.ThrowsAsync(() => 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(() => 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(e.InnerException); + Assert.Equal(message2, e.InnerException.Message); + } + } + + } +} diff --git a/Sources/UnitTesting/CodeInvalideExceptionUT.cs b/Sources/UnitTesting/CodeInvalideExceptionUT.cs new file mode 100644 index 0000000..57fcf60 --- /dev/null +++ b/Sources/UnitTesting/CodeInvalideExceptionUT.cs @@ -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(() => throw new CodeInvalideException()); + } + + [Fact] + public void ExceptionAttributs() + { + Assert.ThrowsAsync(() => 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(() => 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(() => 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(e.InnerException); + Assert.Equal(message2, e.InnerException.Message); + } + } + + } +} diff --git a/Sources/UnitTesting/CodeVideExceptionUT.cs b/Sources/UnitTesting/CodeVideExceptionUT.cs new file mode 100644 index 0000000..650dc3a --- /dev/null +++ b/Sources/UnitTesting/CodeVideExceptionUT.cs @@ -0,0 +1,54 @@ +using CoreLibrary.Exceptions; +using Xunit; + +namespace UnitTesting +{ + public class CodeVideExceptionUT + { + [Fact] + public void ExceptionDefaut() + { + Assert.ThrowsAsync(() => throw new CodeVideException()); + } + + [Fact] + public void ExceptionMessage() + { + string message = "Mon super gros problème."; + + Assert.ThrowsAsync(() => 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(() => 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(e.InnerException); + Assert.Equal(message2, e.InnerException.Message); + } + } + + } +} diff --git a/Sources/UnitTesting/IndiceCodeExceptionUT.cs b/Sources/UnitTesting/IndiceCodeExceptionUT.cs new file mode 100644 index 0000000..50e40c4 --- /dev/null +++ b/Sources/UnitTesting/IndiceCodeExceptionUT.cs @@ -0,0 +1,70 @@ +using CoreLibrary.Exceptions; +using Xunit; + +namespace UnitTesting +{ + public class IndiceCodeExceptionUT + { + [Fact] + public void ExceptionDefaut() + { + Assert.ThrowsAsync(() => throw new IndiceCodeException()); + } + + [Fact] + public void ExceptionAttributs() + { + Assert.ThrowsAsync(() => 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(() => 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(() => 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(e.InnerException); + Assert.Equal(message2, e.InnerException.Message); + } + } + + } +} diff --git a/Sources/UnitTesting/PartieNonCommenceeExceptionUT.cs b/Sources/UnitTesting/PartieNonCommenceeExceptionUT.cs new file mode 100644 index 0000000..c0733cf --- /dev/null +++ b/Sources/UnitTesting/PartieNonCommenceeExceptionUT.cs @@ -0,0 +1,54 @@ +using CoreLibrary.Exceptions; +using Xunit; + +namespace UnitTesting +{ + public class PartieNonCommenceeExceptionUT + { + [Fact] + public void ExceptionDefaut() + { + Assert.ThrowsAsync(() => throw new PartieNonCommenceeException()); + } + + [Fact] + public void ExceptionMessage() + { + string message = "Mon super gros problème."; + + Assert.ThrowsAsync(() => 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(() => 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(e.InnerException); + Assert.Equal(message2, e.InnerException.Message); + } + } + + } +} diff --git a/Sources/UnitTesting/TailleCodeExceptionUT.cs b/Sources/UnitTesting/TailleCodeExceptionUT.cs new file mode 100644 index 0000000..eda2056 --- /dev/null +++ b/Sources/UnitTesting/TailleCodeExceptionUT.cs @@ -0,0 +1,69 @@ +using CoreLibrary.Exceptions; +using Xunit; + +namespace UnitTesting +{ + public class TailleCodeExceptionUT + { + [Fact] + public void ExceptionDefaut() + { + Assert.ThrowsAsync(() => throw new TailleCodeException()); + } + + [Fact] + public void ExceptionAttributs() + { + Assert.ThrowsAsync(() => 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(() => 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(() => 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(e.InnerException); + Assert.Equal(message2, e.InnerException.Message); + } + } + + } +} diff --git a/Sources/UnitTesting/TailleGrilleExceptionUT.cs b/Sources/UnitTesting/TailleGrilleExceptionUT.cs new file mode 100644 index 0000000..8063a17 --- /dev/null +++ b/Sources/UnitTesting/TailleGrilleExceptionUT.cs @@ -0,0 +1,69 @@ +using CoreLibrary.Exceptions; +using Xunit; + +namespace UnitTesting +{ + public class TailleGrilleExceptionUT + { + [Fact] + public void ExceptionDefaut() + { + Assert.ThrowsAsync(() => throw new TailleGrilleException()); + } + + [Fact] + public void ExceptionAttributs() + { + Assert.ThrowsAsync(() => 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(() => 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(() => 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(e.InnerException); + Assert.Equal(message2, e.InnerException.Message); + } + } + + } +}