diff Library/LibrarySystem.Tests/Core/BookTests.cs @ 43:aef06698d9e2 Test

Added the library tests
author Steven Hollidge <stevenhollidge@hotmail.com>
date Wed, 04 Apr 2012 19:20:20 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Library/LibrarySystem.Tests/Core/BookTests.cs	Wed Apr 04 19:20:20 2012 +0100
@@ -0,0 +1,42 @@
+using System;
+using LibrarySystem.Core;
+using LibrarySystem.Interfaces;
+using NUnit.Framework;
+
+namespace LibrarySystem.Tests.Core
+{
+    [TestFixture]
+    class BookTests
+    {
+        [Test]
+        public void Create_WithNullIdAndNullPublication_ShouldThrowArgumentNullException()
+        {
+            Assert.Throws<ArgumentNullException>(() => Book.Create(null, null));
+        }
+
+        [Test]
+        public void Create_WithNullIdAndValidPublication_ShouldThrowArgumentNullException()
+        {
+            var publisher = Publisher.Create("dummy");
+            var publication = Publication.Create("dummy", "dummy", publisher, "dummy");
+            Assert.Throws<ArgumentNullException>(() => Book.Create(null, publication));
+        }
+
+        [Test]
+        public void Create_WithNullPublication_ShouldThrowArgumentNullException()
+        {
+            var validId = "1";
+            Assert.Throws<ArgumentNullException>(() => Book.Create(validId, null));
+        }
+
+        [Test]
+        public void Create_WithValidParametersPublication_ShouldReturnBook()
+        {
+            var publisher = Publisher.Create("dummy");
+            var publication = Publication.Create("dummy","dummy", publisher, "dummy");
+            var validId = "1";
+            IBook book = Book.Create(validId, publication);
+            Assert.NotNull(book);
+        }
+    }
+}
\ No newline at end of file