From 96cc9a1f35b0c6f8fb70d0084de896698d9cd7af Mon Sep 17 00:00:00 2001 From: "shannon@ShandemVaio" Date: Tue, 17 Jul 2012 01:33:14 +0600 Subject: [PATCH] Missing file updates --- test/umbraco.Test/ApplicationTest.cs | 46 ++++++++++++++++++++-------- test/umbraco.Test/AuthoringTests.txt | 10 +++++- test/umbraco.Test/DocumentTest.cs | 14 ++++----- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/test/umbraco.Test/ApplicationTest.cs b/test/umbraco.Test/ApplicationTest.cs index 8469efef52..fb6e9ef35a 100644 --- a/test/umbraco.Test/ApplicationTest.cs +++ b/test/umbraco.Test/ApplicationTest.cs @@ -1,21 +1,43 @@ -using umbraco.BusinessLogic; +using System.Collections.Generic; +using System.Configuration; +using umbraco; +using umbraco.BusinessLogic; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -using umbraco.interfaces; -using System.Collections.Generic; using umbraco.DataLayer; using System.Linq; -namespace umbraco.Test +namespace Umbraco.LegacyTests { - - - /// + [TestClass()] + public abstract class BaseTest + { + [TestInitialize] + public void Initialize() + { + ConfigurationManager.AppSettings.Set("umbracoDbDSN", @"datalayer=SQLCE4Umbraco.SqlCEHelper,SQLCE4Umbraco;data source=|DataDirectory|\Umbraco.sdf"); + + var dataHelper = DataLayerHelper.CreateSqlHelper(GlobalSettings.DbDSN); + var installer = dataHelper.Utility.CreateInstaller(); + if (installer.CanConnect) + { + installer.Install(); + } + + Application.Apps = new List() + { + new Application("content", "content", "content", 0) + }; + } + } + + +/// ///This is a test class for ApplicationTest and is intended ///to contain all ApplicationTest Unit Tests /// [TestClass()] - public class ApplicationTest + public class ApplicationTest : BaseTest { /// @@ -50,18 +72,18 @@ namespace umbraco.Test var user = User.MakeNew(name, name, name, ut); //get application - var app = Application.getAll().First(); + //var app = Application.getAll().First(); //assign the app - user.addApplication(app.alias); + user.addApplication("content"); //ensure it's added - Assert.AreEqual(1, user.Applications.Where(x => x.alias == app.alias).Count()); + Assert.AreEqual(1, user.Applications.Count(x => x.alias == "content")); //delete the user user.delete(); //make sure the assigned applications are gone - Assert.AreEqual(0, user.Applications.Where(x => x.alias == name).Count()); + Assert.AreEqual(0, user.Applications.Count(x => x.alias == name)); } /// diff --git a/test/umbraco.Test/AuthoringTests.txt b/test/umbraco.Test/AuthoringTests.txt index 587aabf469..2fe8f08b49 100644 --- a/test/umbraco.Test/AuthoringTests.txt +++ b/test/umbraco.Test/AuthoringTests.txt @@ -19,4 +19,12 @@ You can do this from the 'Test' menu item and select run all tests in solution) and see if it works (For some reason on my machine in VS2010, i can't have the website running while i run the unit tests, in VS2008 this did work) ** If the tests don't work, you'll need to investigate why... could be just a config issue, a data issue or could -just be bugs and the tests only work on my machine :) \ No newline at end of file +just be bugs and the tests only work on my machine :) + +**** DEBUGGING INFO ******* + +debugging unit tests for ASP.Net (because it runs in a context) can't be debugged directly in the same VS as your running the tests. + +Unfortunately the only way to do it is to add this line to your unit test you want to debug: + +System.Diagnostics.Debugger.Launch(); \ No newline at end of file diff --git a/test/umbraco.Test/DocumentTest.cs b/test/umbraco.Test/DocumentTest.cs index 207b5d4d1e..bfc0a55ddb 100644 --- a/test/umbraco.Test/DocumentTest.cs +++ b/test/umbraco.Test/DocumentTest.cs @@ -1,22 +1,19 @@ -using System.Diagnostics; -using umbraco.cms.businesslogic.web; +using umbraco.cms.businesslogic.web; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using umbraco.BusinessLogic; using umbraco.cms.businesslogic; using System.Collections.Generic; using System.Xml; -using Microsoft.VisualStudio.TestTools.UnitTesting.Web; using System.Linq; using System.Threading; using umbraco.cms.businesslogic.datatype; using umbraco.editorControls.textfield; -using umbraco.cms.businesslogic.propertytype; using umbraco.cms.businesslogic.property; using umbraco.cms.businesslogic.language; using umbraco.BusinessLogic.console; -namespace umbraco.Test +namespace Umbraco.LegacyTests { @@ -864,13 +861,14 @@ namespace umbraco.Test /// internal static int GetExistingDocTypeId() { + System.Diagnostics.Debugger.Launch(); + var types = DocumentType.GetAllAsList(); DocumentType found = null; - TextFieldDataType txtField = new TextFieldDataType(); + var txtField = new TextFieldDataType(); foreach (var d in types) { - var prop = d.PropertyTypes - .Where(x => x.DataTypeDefinition.DataType.Id == txtField.Id).FirstOrDefault(); + var prop = d.PropertyTypes.FirstOrDefault(x => x.DataTypeDefinition.DataType.Id == txtField.Id); if (prop != null) { found = d;