WhiteBoxTesting.cs

00001 using System;
00002 using System.Collections.Generic;
00003 using System.Text;
00004 using NUnit.Framework;
00005 using Shared;
00006 using Server.Data;
00007 
00008 namespace Server.Test
00009 {
00013     [TestFixture]
00014     public class WhiteBoxTesting
00015     {
00016         IPersistentData pd;
00017         Catalogue catalogue;
00018         
00022         [SetUp]
00023         public void Init()
00024         {
00025             pd = new DummyData();
00026             catalogue = new Catalogue(pd);
00027 
00028             catalogue.RegisterUser("username", "123", "name", "department", "my email");
00029         }
00030 
00034         [Test]
00035         public void IndependentPathTest1() 
00036         {
00037             List<SearchResult> results = catalogue.Search("tv", ResultType.Literature);
00038             Assert.AreEqual(0, results.Count, "Results count");
00039         }
00040 
00044         [Test]
00045         public void IndependentPathTest2()
00046         {
00047             List<SearchResult> results = catalogue.Search("something", ResultType.Comment);
00048             Assert.AreEqual(0, results.Count, "Results count");
00049         }
00050 
00054         [Test]
00055         public void IndependentPathTest3()
00056         {
00057             List<SearchResult> results = catalogue.Search("something", ResultType.Literature);
00058             Assert.AreEqual(0, results.Count, "Results count");
00059         }
00060 
00064         [Test]
00065         public void IndependentPathTest4()
00066         {
00067             int id;
00068             catalogue.CreateLiterature(new LiteratureInfo(-1, "username", "isbn", "title", "author", "testsummary", "source", DateTime.Now,
00069                 LiteratureType.Journal), out id);
00070             List<SearchResult> results = catalogue.Search("title", ResultType.Literature);
00071 
00072             Assert.AreEqual(1, results.Count, "Results count");
00073             LiteratureInfo li = (LiteratureInfo)results[0].Item;
00074             Assert.AreEqual("testsummary", li.summary, "Summary compare");
00075         }
00076 
00080         [Test]
00081         public void IndependentPathTest5()
00082         {
00083             List<SearchResult> results = catalogue.Search("notme", ResultType.Person);
00084             Assert.AreEqual(0, results.Count, "Results count");
00085         }
00086 
00090         [Test]
00091         public void IndependentPathTest6()
00092         {
00093             List<SearchResult> results = catalogue.Search("name", ResultType.Person);
00094             Assert.AreEqual(1, results.Count, "Results count 1");
00095             
00096             results = catalogue.Search("username", ResultType.Person);
00097             Assert.AreEqual(1, results.Count, "Results count 2");
00098 
00099             PersonInfo pi = (PersonInfo)results[0].Item;
00100             Assert.AreEqual("my email", pi.email, "Email compare");
00101         }
00102 
00106         [Test]
00107         public void IndependentPathTest7() 
00108         {
00109             List<SearchResult> results = catalogue.Search("a project", ResultType.Project);
00110             Assert.AreEqual(0, results.Count, "Results count");
00111         }
00112 
00116         [Test]
00117         public void IndependentPathTest8()
00118         {
00119             int id;
00120             catalogue.CreateProject(new ProjectInfo(-1, DateTime.Now, DateTime.Now,
00121                 "", "test title", "", "test synopsis", false), "username", out id);
00122 
00123             List<SearchResult> results = catalogue.Search("test title", ResultType.Project);
00124             Assert.AreEqual(1, results.Count, "Results count");
00125 
00126             Assert.IsTrue(results[0].Item is ProjectInfo, "Type test");
00127 
00128             ProjectInfo pi = (ProjectInfo)results[0].Item;
00129             Assert.AreEqual("test synopsis", pi.synopsis, "Synopsis compare");
00130         }
00131 
00135         [Test]
00136         public void IndependentPathTest9() 
00137         {
00138             List<SearchResult> results = catalogue.Search("a review", ResultType.Review);
00139             Assert.AreEqual(0, results.Count, "Results count");
00140         }
00141 
00145         [Test]
00146         public void IndependentPathTest10()
00147         {
00148             int literature;
00149             int project;
00150             catalogue.CreateLiterature(new LiteratureInfo(-1, "username", "isbn", "title", "author", "testsummary", "source", DateTime.Now,
00151                 LiteratureType.Journal), out literature);
00152             catalogue.CreateProject(new ProjectInfo(-1, DateTime.Now, DateTime.Now, "", "test title", "", 
00153                 "test synopsis", false), "username", out project);
00154 
00155             catalogue.CreateReview(new ReviewInfo(project, literature, DateTime.Now, false, "", "username", "test title", "test text", 0));
00156 
00157             List<SearchResult> results = catalogue.Search("test text", ResultType.Review);
00158             Assert.AreEqual(1, results.Count, "Results count");
00159         }
00160 
00161     }
00162 }

Generated on Thu Dec 21 06:21:56 2006 for SCRAML by  doxygen 1.5.1-p1