Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Developing Next Generation Smart Clients using .NET 2.0 working with Existing .NET 1.1 SOA-based XML Web Services

, 16 Aug 2005
Comprehensive guide to development of .NET 2.0 Smart Clients working with existing Service Oriented Architecture based XML web services, fully utilizing the Enterprise Library
smartclientsoa_src.zip
SmartClient
Client
SMI.App
Controls
Forms
Modules
Properties
app.manifest
Settings.settings
Resources
240.png
Bottom.png
BuilderDialog_delete.bmp
DarkBlue.bmp
download-xp.gif
Earth.png
fldropen.png
iSync.gif
Leonardo_da_Vinci_My_Computer.png
LightBlue.bmp
LoginBox.jpg
LoginButton.jpg
LoginButton1.jpg
LoginButton2.jpg
Logo1.png
LogoPic.jpg
Middle.png
Refresh.bmp
refresh.ico
refresh1.ico
RightArrow.bmp
SuccessComplete.bmp
Task.bmp
Tasks.png
Top.png
TurnOffButton.bmp
wi0062-32.ico
wi0063-32.ico
wi0064-16.ico
wi0064-32.ico
SmartInstitute.App.csproj.user
wi0064-32.ico
SMI.Automation
Commands
Course
Framework
Security
Students
UI
Controls
Documents
MiscDocuments
StudentDocuments
Factories
Forms
Helpers
Misc
Properties
Settings.settings
Resources
BuilderDialog_delete.bmp
LogoSmall.bmp
Misho.jpg
My Pic 7.jpg
table.ico
SmartInstitute.Automation.csproj.user
Web References
SmartInstituteServices.AccountService
Account.datasource
AccountService.disco
AccountService.wsdl
Reference.map
SmartInstituteServices.CourseService
Course.datasource
CourseService.disco
CourseService.wsdl
Reference.map
SmartInstituteServices.SecurityService
Reference.map
SecurityService.disco
SecurityService.wsdl
SmartInstituteServices.StudentService
Reference.map
Student.datasource
StudentService.disco
StudentService.wsdl
SMI.ObjectModel.Enhanced
Base
Models
Properties
Settings.settings
Settings
SmartInstitute.ObjectModel.csproj.user
UMS.ObjectModel.Enhanced.csproj.user
SMI.Objects
SmartInstitute.csproj.user
CodeSmith
Tier
BusinessLogicLayer
Entity.cst
EntityBase.cst
EntityCollection.cst
EntityCollectionBase.cst
Enum.cst
IEntity.cst
DataAccessLayer
App.config.cst
CommonSql.cst
Configuration.cst
DBConcurrencyException.cst
DBException.cst
Factories
EntityRepositoryFactory.cst
IEntityRepository.cst
SqlClient
CVS
Entries
Entries.Extra
Entries.Extra.Old
Entries.Old
Repository
Root
TortoiseCVS.Status
SqlEntityRepository.cst
SqlEntityRepositoryBase.cst
TransactionManager.cst
UnitTests
EntityRepositoryTest.cst
WebServiceClient
WsEntityRepository.cst
WsEntityRepositoryBase.cst
Main.cst
nant.cst
References
GotDotNet.ApplicationBlocks.Data.dll
Microsoft.ApplicationBlocks.Data.dll
nunit.framework.dll
StoredProcedures.cst
vsnet2003.project.cst
vsnet2003.solution.cst
vsnet2005.project.cst
vsnet2005.solution.cst
WebService
Web.config.cst
WebService.cst
Database
SmartInstitute.bak
Library
Microsoft.Practices.EnterpriseLibrary.Caching.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Security.ActiveDirectory.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cache.CachingStore.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll
Microsoft.Practices.EnterpriseLibrary.Security.Database.Authentication.dll
Microsoft.Practices.EnterpriseLibrary.Security.Database.dll
Microsoft.Practices.EnterpriseLibrary.Security.dll
nunit.core.dll
nunit.framework.dll
Server
BLL
SmartInstitute.csproj.user
DAL
Factories
SmartInstitute.DataAccessLayer.csproj.user
SqlClient
Utilities
GotDotNet.ApplicationBlocks.Data.dll
Microsoft.ApplicationBlocks.Data.dll
nunit.framework.dll
UnitTests
SmartInstitute.build
SmartInstitute.Facade
FacadeTest
SmartInstitute.Facade.csproj.user
SmartInstitute.Test
App.ico
SmartInstitute.Test.csproj.user
SmartInstituteServices
Global.asax
log
SmartInstituteServices.csproj.webinfo
SQL
Setup
SecurityDatabase
SecurityDatabaseConsole
App.ico
SecurityDatabaseConsole.exe.manifest
SR.strings
Tests
Tools.SecurityDatabaseConsole.csproj.user
// =====================================================================================
// Copyright © 2005 by . All rights are reserved.
// 
// If you like this code then feel free to go ahead and use it.
// The only thing I ask is that you don't remove or alter my copyright notice.
//
// Your use of this software is entirely at your own risk. I make no claims or
// warrantees about the reliability or fitness of this code for any particular purpose.
// If you make changes or additions to this code please mark your code as being yours.
// 
// website , email OmarALZabir@gmail.com, msn oazabir@hotmail.com
// =====================================================================================



using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using NUnit.Framework;
using SmartInstitute.DataAccessLayer.Factories;

namespace SmartInstitute.DataAccessLayer.UnitTests
{
    /// <summary>
    /// Provides tests for the and UserGroupPermission objects (entity, collection and repository).
    /// </summary>
    [TestFixture]
    public class UserGroupPermissionRepositoryTest
    {
    	// the UserGroupPermission instance used to test the repository.
		private UserGroupPermission mock;
		
		// the UserGroupPermissionCollection instance used to test the repository.
		UserGroupPermissionCollection mockCollection;
		
		/// <summary>
		/// Creates a new <see cref="UserGroupPermissionRepositoryTest"/> instance.
		/// </summary>	
		public UserGroupPermissionRepositoryTest()
		{			
			this.mock = (UserGroupPermission)CreateMockInstance();	
		}
        
        /// <summary>
		/// This method is used to construct the test environment prior to running the tests.
		/// </summary>
        [TestFixtureSetUp]
        public void Init()
        {
			System.Console.WriteLine(new String('-', 75));
			//System.Console.WriteLine("-- Testing the UserGroupPermission Entity with the " + Configuration.Settings.ClientType + " --");
			System.Console.WriteLine(new String('-', 75));
        }
    
    	/// <summary>
		/// This method is used to restore the environment after the tests are completed.
		/// </summary>
        [TestFixtureTearDown]
        public void Dispose()
        {       	
			System.Console.WriteLine();
			System.Console.WriteLine();
        }
    
    
		/// <summary>
		/// Inserts a mock UserGroupPermission entity into the database.
		/// </summary>
		[Test]
		public void Step_1_Insert()
		{			
			Assert.IsTrue(UserGroupPermissionRepository.Current.Insert(this.mock), "Insert failed");
			System.Console.WriteLine("UserGroupPermissionRepository.Current.Insert(this.mock):");			
			System.Console.WriteLine(this.mock);
		}
		
		
		/// <summary>
		/// Selects all UserGroupPermission objects of the database.
		/// </summary>
		[Test]
		public void Step_2_SelectAll()
		{
			mockCollection = UserGroupPermissionRepository.Current.GetAll();
			Assert.IsTrue(mockCollection.Count > 0, "No records returned.");
			System.Console.WriteLine("UserGroupPermissionRepository.Current.GetAll():");			
			System.Console.WriteLine(mockCollection);
			
			if (mockCollection.Count > 0)
			{
				UserGroupPermissionRepository.Current.DeepLoad(mockCollection[0]);
			}
		}
		
		/// <summary>
		/// Deep load all UserGroupPermission children.
		/// </summary>
		[Test]
		public void Step_3_DeepLoad()
		{
			if (mockCollection.Count > 0)
			{
				mockCollection.Shuffle();			
				UserGroupPermissionRepository.Current.DeepLoad(mockCollection[0]);
				System.Console.WriteLine("UserGroupPermission instance correctly deep loaded at 1 level.");
				
				mockCollection.Shuffle();
				UserGroupPermissionRepository.Current.DeepLoad(mockCollection[0], true);
				System.Console.WriteLine("UserGroupPermission instance correctly deep loaded at N level.");
			}
			
			
		}
		
		/// <summary>
		/// Updates a mock UserGroupPermission entity into the database.
		/// </summary>
		[Test]
		public void Step_4_Update()
		{
			this.mock = UpdateMockInstance(this.mock);
			Assert.IsTrue(UserGroupPermissionRepository.Current.Update(this.mock), "Update failed.");			
		
			// TODO : select sur l'id
			// TODO : verif si l'object recup? est egal
			
			System.Console.WriteLine("UserGroupPermissionRepository.Current.Update(this.mock):");			
			System.Console.WriteLine(this.mock);
		}
		
		
		/// <summary>
		/// Delete the mock UserGroupPermission entity into the database.
		/// </summary>
		[Test]
		public void Step_5_Delete()
		{
			Assert.IsTrue(UserGroupPermissionRepository.Current.Delete(this.mock), "Delete failed.");
			System.Console.WriteLine("UserGroupPermissionRepository.Current.Delete(this.mock):");			
			System.Console.WriteLine(this.mock);
		}
		
		#region Serialization tests
		
		/// <summary>
		/// Serialize the mock UserGroupPermission entity into a temporary file.
		/// </summary>
		[Test]
		public void Step_6_SerializeEntity()
		{
			string fileName = "temp_UserGroupPermission.xml";
		
			XmlSerializer mySerializer = new XmlSerializer(typeof(UserGroupPermission)); 
			StreamWriter myWriter = new StreamWriter(fileName); 
			mySerializer.Serialize(myWriter, this.mock); 
			myWriter.Close();
			System.Console.WriteLine("this.mock correctly serialized to a temporary file.");			
		}
		
		/// <summary>
		/// Deserialize the mock UserGroupPermission entity from a temporary file.
		/// </summary>
		[Test]
		public void Step_7_DeserializeEntity()
		{
			string fileName = "temp_UserGroupPermission.xml";
		
			XmlSerializer mySerializer = new XmlSerializer(typeof(UserGroupPermission)); 
			FileStream myFileStream = new FileStream(fileName,  FileMode.Open); 
			this.mock = (UserGroupPermission) mySerializer.Deserialize(myFileStream);
			myFileStream.Close();
			File.Delete(fileName);
			
			System.Console.WriteLine("this.mock correctly deserialized from a temporary file.");
		}
		
		/// <summary>
		/// Serialize a UserGroupPermission collection into a temporary file.
		/// </summary>
		[Test]
		public void Step_8_SerializeCollection()
		{
			string fileName = "temp_UserGroupPermissionCollection.xml";
		
			UserGroupPermissionCollection mockCollection = new UserGroupPermissionCollection();
			mockCollection.Add(this.mock);
		
			XmlSerializer mySerializer = new XmlSerializer(typeof(UserGroupPermissionCollection)); 
			StreamWriter myWriter = new StreamWriter(fileName); 
			mySerializer.Serialize(myWriter, mockCollection); 
			myWriter.Close();
			
			System.Console.WriteLine("UserGroupPermissionCollection correctly serialized to a temporary file.");					
		}
		
		
		/// <summary>
		/// Deserialize a UserGroupPermission collection from a temporary file.
		/// </summary>
		[Test]
		public void Step_9_DeserializeCollection()
		{
			string fileName = "temp_UserGroupPermissionCollection.xml";
		
			XmlSerializer mySerializer = new XmlSerializer(typeof(UserGroupPermissionCollection)); 
			FileStream myFileStream = new FileStream(fileName,  FileMode.Open); 
			UserGroupPermissionCollection mockCollection = (UserGroupPermissionCollection) mySerializer.Deserialize(myFileStream);
			myFileStream.Close();
			File.Delete(fileName);
			System.Console.WriteLine("UserGroupPermissionCollection correctly deserialized from a temporary file.");	
		}
		#endregion
						
		#region Mock Instance
		///<summary>
		///  Returns a Typed UserGroupPermission Entity with mock values.
		///</summary>
		public UserGroupPermission CreateMockInstance()
		{		
			UserGroupPermission mock = new UserGroupPermission();
						
			mock.PermissionID = (int)12; /*new Guid("20E43088-4618-4F4A-B8AD-FC31B50D94CD")*/
			mock.Granted = false; /*new Guid("20E43088-4618-4F4A-B8AD-FC31B50D94CD")*/
			mock.ChangeStamp = new DateTime(2005, 7, 24, 23, 7, 30, 625); /*new Guid("20E43088-4618-4F4A-B8AD-FC31B50D94CD")*/
			UserGroupCollection _collection0 = UserGroupRepository.Current.GetAll();
			_collection0.Shuffle();
			if (_collection0.Count > 0)
			{
				mock.UserGroupID = _collection0[0].ID;
			}
		   return (UserGroupPermission)mock;
		}
		
		
		///<summary>
		///  Update the Typed UserGroupPermission Entity with modified mock values.
		///</summary>
		public UserGroupPermission UpdateMockInstance(UserGroupPermission mock)
		{
			mock.PermissionID = (int)13;
			mock.Granted = true;
			mock.ChangeStamp = new DateTime(2005, 7, 24, 23, 7, 30, 625);
			UserGroupCollection _collection0 = UserGroupRepository.Current.GetAll();
			_collection0.Shuffle();
			if (_collection0.Count > 0)
			{
				mock.UserGroupID = _collection0[0].ID;
			}
		   return (UserGroupPermission)mock;
		}
		
		#endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author


| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 17 Aug 2005
Article Copyright 2005 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid