Skip to content

Commit

Permalink
renaming unit tests and creating unit testing for DataValidator. rela…
Browse files Browse the repository at this point in the history
…ted #1
  • Loading branch information
andreazevedo committed Aug 9, 2011
1 parent 87251da commit 985a669
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Test/PetStore.Core.Test/Helper/CheckTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CheckTest
public class ArgumentTest
{
[Test]
public void IsNotNullOrEmptyShouldReturnCorrectResult()
public void IsNotNullOrEmpty_ShouldReturnCorrectResult()
{
string str = "Uma string";

Expand All @@ -23,7 +23,7 @@ public void IsNotNullOrEmptyShouldReturnCorrectResult()

[Test]
[ExpectedException(typeof(ArgumentException))]
public void IsNotNullOrEmptyShouldThrowException()
public void IsNotNullOrEmpty_ShouldThrowException()
{
string str = String.Empty;

Expand All @@ -32,15 +32,15 @@ public void IsNotNullOrEmptyShouldThrowException()

[Test]
[ExpectedException(typeof(ArgumentException))]
public void IsNotNullOrEmptyShouldThrowException2()
public void IsNotNullOrEmpty_ShouldThrowException2()
{
string str = null;

Check.Argument.IsNotNullOrEmpty(str, "argument1");
}

[Test]
public void IsNotNullShouldReturnCorrectResult()
public void IsNotNull_ShouldReturnCorrectResult()
{
object obj = new object();

Expand All @@ -49,15 +49,15 @@ public void IsNotNullShouldReturnCorrectResult()

[Test]
[ExpectedException(typeof(ArgumentException))]
public void IsNotNullShouldThrowException()
public void IsNotNull_ShouldThrowException()
{
object obj = null;

Check.Argument.IsNotNull(obj, "argument1");
}

[Test]
public void IsInRangeShouldReturnCorrectResult()
public void IsInRange_ShouldReturnCorrectResult()
{
const int min = 0;
const int max = 100;
Expand All @@ -68,7 +68,7 @@ public void IsInRangeShouldReturnCorrectResult()
}

[Test]
public void IsInRangeShouldReturnCorrectResult2()
public void IsInRange_ShouldReturnCorrectResult2()
{
const int min = 0;
const int max = 100;
Expand All @@ -79,7 +79,7 @@ public void IsInRangeShouldReturnCorrectResult2()
}

[Test]
public void IsInRangeShouldReturnCorrectResult3()
public void IsInRange_ShouldReturnCorrectResult3()
{
const int min = 0;
const int max = 100;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -114,7 +114,7 @@ public void IsInRangeShouldThrowException2()
}

[Test]
public void IsNotInPastShouldReturnCorrectResult()
public void IsNotInPast_ShouldReturnCorrectResult()
{
DateTime dateTime = DateTime.Now.AddMinutes(1);

Expand All @@ -123,15 +123,15 @@ public void IsNotInPastShouldReturnCorrectResult()

[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void IsNotInPastShouldThrowException()
public void IsNotInPast_ShouldThrowException()
{
DateTime dateTime = DateTime.Now.AddSeconds(-1);

Check.Argument.IsNotInPast(dateTime, "date");
}

[Test]
public void IsNotNegativeOrZeroShouldReturnCorrectResult()
public void IsNotNegativeOrZero_ShouldReturnCorrectResult()
{
TimeSpan timeSpan = TimeSpan.FromMilliseconds(1);

Expand All @@ -140,7 +140,7 @@ public void IsNotNegativeOrZeroShouldReturnCorrectResult()

[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void IsNotNegativeOrZeroShouldThrowException()
public void IsNotNegativeOrZero_ShouldThrowException()
{
TimeSpan timeSpan = TimeSpan.FromMilliseconds(0);

Expand All @@ -149,7 +149,7 @@ public void IsNotNegativeOrZeroShouldThrowException()

[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void IsNotNegativeOrZeroShouldThrowException2()
public void IsNotNegativeOrZero_ShouldThrowException2()
{
TimeSpan timeSpan = TimeSpan.FromMilliseconds(-1);

Expand Down
32 changes: 32 additions & 0 deletions src/Test/PetStore.Core.Test/Helper/DataValidatorTest.cs
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]";

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);
}
}
}
1 change: 1 addition & 0 deletions src/Test/PetStore.Core.Test/PetStore.Core.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Helper\CheckTest.cs" />
<Compile Include="Helper\DataValidatorTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 985a669

Please sign in to comment.