Revision: 164
http://svn.sourceforge.net/nmailserver/?rev=164&view=rev
Author: tmyroadctfig
Date: 2007-03-03 21:32:53 -0800 (Sat, 03 Mar 2007)
Log Message:
-----------
Moved stuff around.
Modified Paths:
--------------
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs
NMail/trunk/NMail.UnitTests/SmtpService/SmtpServiceTests.cs
Removed Paths:
-------------
NMail/trunk/NMail.UnitTests/LocalStoreData/MySql/
NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs 2007-03-04 05:32:53 UTC (rev 164)
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Calendar tests for the local store data.
+ /// </summary>
+ [TestFixture]
+ public class CalendarTests {
+
+ ILocalStoreData localStoreData;
+
+ [TestFixtureSetUp]
+ public void Setup() {
+ localStoreData = NMailConfiguration.Current.LocalStoreData;
+
+ localStoreData.ReinstallSchema();
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown() {
+ localStoreData.ReinstallSchema();
+ }
+
+ public void CreateCalendar(string name, int ownerId, int parentId) {
+ Calendar c1 = new Calendar();
+ c1.Name = name;
+ c1.OwnerUserId = ownerId;
+ c1.ParentFolderId = parentId;
+
+ localStoreData.SaveCalandar(c1);
+ }
+
+ public void DeleteCalendar(int calendarId) {
+ localStoreData.DeleteCalandar(calendarId);
+ }
+
+ [Test]
+ public void TestCreateCalendar() {
+ CreateCalendar("Test", 1, 1);
+
+ // Clean up
+ Calendar c = localStoreData.GetCalandar("Test", 1);
+ DeleteCalendar(c.CalendarId);
+ }
+
+ [Test]
+ public void TestCreateCalendarDuplicate() {
+ CreateCalendar("Test", 1, 1);
+
+ try {
+ CreateCalendar("Test", 1, 1);
+
+ Assert.Fail("Allowed duplicate calendar names.");
+
+ } catch (ArgumentException ex) {
+ // Ignore
+ }
+
+ // Clean up
+ Calendar c = localStoreData.GetCalandar("Test", 1);
+ localStoreData.DeleteCalandar(c.CalendarId);
+ }
+
+ [Test]
+ public void TestCreateEventEntry() {
+ CreateCalendar("Test", 1, 1);
+
+ Calendar c1 = localStoreData.GetCalandar("Test", 1);
+
+ DateTime startTime = DateTime.Now;
+ EventEntry e1 = new EventEntry();
+ e1.Calendar = c1;
+ e1.Categories.Add("Sample category.");
+ e1.Classification = NMail.DataTypes.Classification.Private;
+ e1.StartTime = startTime;
+
+ localStoreData.SaveCalendarEntry(e1);
+
+ IList<CalendarEntry> entries = localStoreData.GetCalendarEntries(startTime, DateTime.Now, c1.CalendarId);
+
+ Assert.AreEqual(1, entries.Count, "Entries.count == 1");
+ Assert.AreEqual(e1.EntryId, entries[0].EntryId, "e1.EntryId == entries[0].EntryId");
+
+ DeleteCalendar(c1.CalendarId);
+ }
+ }
+}
Copied: NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs (from rev 148, NMail/trunk/NMail.UnitTests/LocalStoreData/MySql/MySqlLocalStoreTests.cs)
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs 2007-03-04 05:32:53 UTC (rev 164)
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Authentication;
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.LocalStoreData.MySql {
+ /// <summary>
+ /// Tests for the MySql localstore.
+ /// </summary>
+ [TestFixture]
+ public class MySqlLocalStoreTests {
+
+ ILocalStoreData localStoreData;
+
+ [TestFixtureSetUp]
+ public void Setup() {
+ localStoreData = NMailConfiguration.Current.LocalStoreData;
+ }
+
+ public const string TestUsername = "testusername";
+
+ public const string TestFolder = "testfolder";
+
+ [Test]
+ public void TestCreateUser() {
+ LocalStoreUserResult result = localStoreData.CreateUser(TestUsername, null, null);
+ Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User created successfully.");
+
+ LocalStoreUser user = localStoreData.GetUser(TestUsername);
+ Assert.IsNotNull(user, "Valid user.");
+ Assert.IsTrue(user.UserId > 0, "Valid user Id");
+ Assert.IsTrue(user.UserFolderId > 0, "Valid user folder Id");
+ }
+
+ [Test]
+ public void CreateFolder() {
+ LocalStoreUser user = localStoreData.GetUser(TestUsername);
+ Assert.IsNotNull(user, "Valid user.");
+
+ // Get the user's initial folder
+ StoreFolder nominal = localStoreData.GetStoreFolder(user.UserFolderId);
+ Assert.IsNotNull(nominal, "Nominal folder not null.");
+
+ // Make a sub-folder under it
+ Folder newFolder = new Folder(nominal, TestFolder);
+ LocalStoreFolderResult result = localStoreData.CreateFolder(user.UserId, nominal, newFolder);
+ Assert.AreEqual(LocalStoreFolderResult.OkSuccessful, result, "Created folder successfully.");
+ }
+
+ [Test]
+ public void TestDeleteUser() {
+ // Make an initial delete attempt (which should fail)
+ int userId = localStoreData.GetUser(TestUsername).UserId;
+ LocalStoreUserResult result = localStoreData.DeleteUser(userId);
+ Assert.AreEqual(LocalStoreUserResult.UserStillHasFolders, result, "User deleted fails with still has folders.");
+
+ // Delete all the user's folders
+ Queue<StoreFolder> folders = new Queue<StoreFolder>(localStoreData.GetUserFolders(userId));
+
+ while (folders.Count > 0) {
+ StoreFolder folder = folders.Dequeue();
+ LocalStoreFolderResult folderResult = localStoreData.DeleteFolder(folder.FolderId);
+
+ if (folderResult == LocalStoreFolderResult.OkSuccessful) {
+ continue;
+
+ } else if (folderResult != LocalStoreFolderResult.HasChildren) {
+ throw new InvalidOperationException(string.Format("Error deleting user's folder. Id: {0}", folder.FolderId));
+
+ } else {
+ folders.Enqueue(folder);
+ }
+ }
+
+ // Attempt to delete the user again
+ result = localStoreData.DeleteUser(userId);
+ Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User deleted successfully.");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-04 05:29:38 UTC (rev 163)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-04 05:32:53 UTC (rev 164)
@@ -50,11 +50,11 @@
<Compile Include="DNSCacheTests.cs" />
<Compile Include="Helper\MimeHelperTests.cs" />
<Compile Include="Helper\StringTokenizerTests.cs" />
- <Compile Include="LocalStoreData\MySql\CalendarTests.cs" />
- <Compile Include="LocalStoreData\MySql\MySqlLocalStoreTests.cs" />
+ <Compile Include="LocalStoreData\CalendarTests.cs" />
+ <Compile Include="LocalStoreData\MySqlLocalStoreTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\ResourceHelper.cs" />
- <Compile Include="SmtpServiceTests.cs" />
+ <Compile Include="SmtpService\SmtpServiceTests.cs" />
<Compile Include="SpoolData\BaseSpoolDataTest.cs" />
<Compile Include="SpoolData\NextDeliveryTest1.cs" />
<Compile Include="SpoolData\FilterTest3.cs" />
Copied: NMail/trunk/NMail.UnitTests/SmtpService/SmtpServiceTests.cs (from rev 148, NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs)
===================================================================
--- NMail/trunk/NMail.UnitTests/SmtpService/SmtpServiceTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/SmtpService/SmtpServiceTests.cs 2007-03-04 05:32:53 UTC (rev 164)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2004-2006 Luke Quinane, Daniel Frampton and Jared Hodges.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Net;
+using System.Net.Sockets;
+
+using NUnit.Framework;
+using log4net;
+
+using NMail.DataTypes;
+using NMail.IO;
+
+namespace NMail.UnitTests.SmtpService {
+ /// <summary>
+ /// Preforms tests on the Smtp Service.
+ /// </summary>
+ [TestFixture]
+ public class SmtpServiceTests {
+ private static ILog log = LogManager.GetLogger(typeof(SmtpServiceTests));
+ private TcpTextConnection connection;
+
+ /// <summary>
+ /// Opens a connection to the server.
+ /// </summary>
+ private void Open() {
+ this.connection = new TcpTextConnection(log);
+ try {
+ this.connection.Open(new Host(IPAddress.Loopback), 25);
+ } catch (System.Net.Sockets.SocketException e) {
+ Assert.Fail(e.Message +
+ "\n(These tests are not standalone - you may need to manually start the SMTP Service.)");
+ }
+
+ // Should get a 220 response
+ string welcome = this.connection.ReadLine();
+ Assert.IsTrue(welcome.StartsWith("220 "), "Welcome starts with '220 '");
+ }
+
+ /// <summary>
+ /// Closes the connection to the server
+ /// </summary>
+ private void Close() {
+ this.connection.WriteLine("QUIT");
+ this.connection.Close();
+ }
+
+ /// <summary>
+ /// Tests that the server sends a "220" welcome message.
+ /// </summary>
+ [Test]
+ public void WelcomeTest() {
+ Open();
+ Close();
+ }
+
+ /// <summary>
+ /// Checks that the server sends a "250 " response to a NOOP command.
+ /// </summary>
+ [Test]
+ public void NoopTest() {
+ Open();
+ this.connection.WriteLine("noop");
+ string response = this.connection.ReadLine();
+ Assert.IsTrue(response.StartsWith("250 "), "NOOP response starts with '250 '");
+ Close();
+ }
+
+ /// <summary>
+ /// Checks that the server sends a "250 " response to HELO command followed by
+ /// a host name.
+ /// </summary>
+ [Test]
+ public void HeloTest() {
+ Open();
+ this.connection.WriteLine("helo test.domain");
+ string response = this.connection.ReadLine();
+ Assert.IsTrue(response.StartsWith("250 "), "HELO response starts with '250 '");
+ Host h1 = new Host(response.Split(' ')[1]);
+ Close();
+ }
+ }
+}
Deleted: NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs 2007-03-04 05:29:38 UTC (rev 163)
+++ NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs 2007-03-04 05:32:53 UTC (rev 164)
@@ -1,97 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane, Daniel Frampton and Jared Hodges.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Net;
-using System.Net.Sockets;
-
-using NUnit.Framework;
-using log4net;
-
-using NMail.DataTypes;
-using NMail.IO;
-
-namespace NMail.Tests.UnitTests {
- /// <summary>
- /// Preforms tests on the Smtp Service.
- /// </summary>
- [TestFixture]
- public class SmtpServiceTests {
- private static ILog log = LogManager.GetLogger(typeof(SmtpServiceTests));
- private TcpTextConnection connection;
-
- /// <summary>
- /// Opens a connection to the server.
- /// </summary>
- private void Open() {
- this.connection = new TcpTextConnection(log);
- try {
- this.connection.Open(new Host(IPAddress.Loopback), 25);
- } catch (System.Net.Sockets.SocketException e) {
- Assert.Fail(e.Message +
- "\n(These tests are not standalone - you may need to manually start the SMTP Service.)");
- }
-
- // Should get a 220 response
- string welcome = this.connection.ReadLine();
- Assert.IsTrue(welcome.StartsWith("220 "), "Welcome starts with '220 '");
- }
-
- /// <summary>
- /// Closes the connection to the server
- /// </summary>
- private void Close() {
- this.connection.WriteLine("QUIT");
- this.connection.Close();
- }
-
- /// <summary>
- /// Tests that the server sends a "220" welcome message.
- /// </summary>
- [Test]
- public void WelcomeTest() {
- Open();
- Close();
- }
-
- /// <summary>
- /// Checks that the server sends a "250 " response to a NOOP command.
- /// </summary>
- [Test]
- public void NoopTest() {
- Open();
- this.connection.WriteLine("noop");
- string response = this.connection.ReadLine();
- Assert.IsTrue(response.StartsWith("250 "), "NOOP response starts with '250 '");
- Close();
- }
-
- /// <summary>
- /// Checks that the server sends a "250 " response to HELO command followed by
- /// a host name.
- /// </summary>
- [Test]
- public void HeloTest() {
- Open();
- this.connection.WriteLine("helo test.domain");
- string response = this.connection.ReadLine();
- Assert.IsTrue(response.StartsWith("250 "), "HELO response starts with '250 '");
- Host h1 = new Host(response.Split(' ')[1]);
- Close();
- }
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|