From 985a66951d157668811a2b258727cf7154c5c312 Mon Sep 17 00:00:00 2001 From: Andre Azevedo Date: Tue, 9 Aug 2011 01:02:53 -0300 Subject: [PATCH] renaming unit tests and creating unit testing for DataValidator. related #1 --- .../PetStore.Core.Test/Helper/CheckTest.cs | 30 ++++++++--------- .../Helper/DataValidatorTest.cs | 32 +++++++++++++++++++ .../PetStore.Core.Test.csproj | 1 + 3 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 src/Test/PetStore.Core.Test/Helper/DataValidatorTest.cs diff --git a/src/Test/PetStore.Core.Test/Helper/CheckTest.cs b/src/Test/PetStore.Core.Test/Helper/CheckTest.cs index 0180d82..e18f919 100644 --- a/src/Test/PetStore.Core.Test/Helper/CheckTest.cs +++ b/src/Test/PetStore.Core.Test/Helper/CheckTest.cs @@ -14,7 +14,7 @@ public class CheckTest public class ArgumentTest { [Test] - public void IsNotNullOrEmptyShouldReturnCorrectResult() + public void IsNotNullOrEmpty_ShouldReturnCorrectResult() { string str = "Uma string"; @@ -23,7 +23,7 @@ public void IsNotNullOrEmptyShouldReturnCorrectResult() [Test] [ExpectedException(typeof(ArgumentException))] - public void IsNotNullOrEmptyShouldThrowException() + public void IsNotNullOrEmpty_ShouldThrowException() { string str = String.Empty; @@ -32,7 +32,7 @@ public void IsNotNullOrEmptyShouldThrowException() [Test] [ExpectedException(typeof(ArgumentException))] - public void IsNotNullOrEmptyShouldThrowException2() + public void IsNotNullOrEmpty_ShouldThrowException2() { string str = null; @@ -40,7 +40,7 @@ public void IsNotNullOrEmptyShouldThrowException2() } [Test] - public void IsNotNullShouldReturnCorrectResult() + public void IsNotNull_ShouldReturnCorrectResult() { object obj = new object(); @@ -49,7 +49,7 @@ public void IsNotNullShouldReturnCorrectResult() [Test] [ExpectedException(typeof(ArgumentException))] - public void IsNotNullShouldThrowException() + public void IsNotNull_ShouldThrowException() { object obj = null; @@ -57,7 +57,7 @@ public void IsNotNullShouldThrowException() } [Test] - public void IsInRangeShouldReturnCorrectResult() + public void IsInRange_ShouldReturnCorrectResult() { const int min = 0; const int max = 100; @@ -68,7 +68,7 @@ public void IsInRangeShouldReturnCorrectResult() } [Test] - public void IsInRangeShouldReturnCorrectResult2() + public void IsInRange_ShouldReturnCorrectResult2() { const int min = 0; const int max = 100; @@ -79,7 +79,7 @@ public void IsInRangeShouldReturnCorrectResult2() } [Test] - public void IsInRangeShouldReturnCorrectResult3() + public void IsInRange_ShouldReturnCorrectResult3() { const int min = 0; const int max = 100; @@ -91,7 +91,7 @@ public void IsInRangeShouldReturnCorrectResult3() [Test] [ExpectedException(typeof(ArgumentOutOfRangeException))] - public void IsInRangeShouldThrowException() + public void IsInRange_ShouldThrowException() { const int min = 0; const int max = 100; @@ -103,7 +103,7 @@ public void IsInRangeShouldThrowException() [Test] [ExpectedException(typeof(ArgumentOutOfRangeException))] - public void IsInRangeShouldThrowException2() + public void IsInRange_ShouldThrowException2() { const int min = 0; const int max = 100; @@ -114,7 +114,7 @@ public void IsInRangeShouldThrowException2() } [Test] - public void IsNotInPastShouldReturnCorrectResult() + public void IsNotInPast_ShouldReturnCorrectResult() { DateTime dateTime = DateTime.Now.AddMinutes(1); @@ -123,7 +123,7 @@ public void IsNotInPastShouldReturnCorrectResult() [Test] [ExpectedException(typeof(ArgumentOutOfRangeException))] - public void IsNotInPastShouldThrowException() + public void IsNotInPast_ShouldThrowException() { DateTime dateTime = DateTime.Now.AddSeconds(-1); @@ -131,7 +131,7 @@ public void IsNotInPastShouldThrowException() } [Test] - public void IsNotNegativeOrZeroShouldReturnCorrectResult() + public void IsNotNegativeOrZero_ShouldReturnCorrectResult() { TimeSpan timeSpan = TimeSpan.FromMilliseconds(1); @@ -140,7 +140,7 @@ public void IsNotNegativeOrZeroShouldReturnCorrectResult() [Test] [ExpectedException(typeof(ArgumentOutOfRangeException))] - public void IsNotNegativeOrZeroShouldThrowException() + public void IsNotNegativeOrZero_ShouldThrowException() { TimeSpan timeSpan = TimeSpan.FromMilliseconds(0); @@ -149,7 +149,7 @@ public void IsNotNegativeOrZeroShouldThrowException() [Test] [ExpectedException(typeof(ArgumentOutOfRangeException))] - public void IsNotNegativeOrZeroShouldThrowException2() + public void IsNotNegativeOrZero_ShouldThrowException2() { TimeSpan timeSpan = TimeSpan.FromMilliseconds(-1); diff --git a/src/Test/PetStore.Core.Test/Helper/DataValidatorTest.cs b/src/Test/PetStore.Core.Test/Helper/DataValidatorTest.cs new file mode 100644 index 0000000..c32f275 --- /dev/null +++ b/src/Test/PetStore.Core.Test/Helper/DataValidatorTest.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; +using PetStore.Core.Helper; + +namespace PetStore.Core.Test.Helper +{ + [TestFixture] + public class DataValidatorTest + { + [Test] + public void IsEmail_ShouldReturnCorrectTrue() + { + const string validEmail = "andre.azevedo@gmail.com"; + + bool result = DataValidator.IsEmail(validEmail); + + Assert.IsTrue(result); + } + [Test] + public void IsEmail_ShouldReturnCorrectFalse() + { + const string invalidEmail = "andre.azevedo"; + + bool result = DataValidator.IsEmail(invalidEmail); + + Assert.IsFalse(result); + } + } +} diff --git a/src/Test/PetStore.Core.Test/PetStore.Core.Test.csproj b/src/Test/PetStore.Core.Test/PetStore.Core.Test.csproj index abe7640..4d4a8fb 100644 --- a/src/Test/PetStore.Core.Test/PetStore.Core.Test.csproj +++ b/src/Test/PetStore.Core.Test/PetStore.Core.Test.csproj @@ -47,6 +47,7 @@ +