Saturday, February 26, 2005

if a class contain just static methods as example i dont need to declare a CTOR, thats good.

extract from FxCop


Error, Certainty 90, for "StaticHolderTypesShouldNotHaveConstructors"
{
Target : "Indexus.AppCommon.TemporaryLogin" (IntrospectionTargetType)
Resolution : "Remove the public constructors from 'TemporaryLogin'.
"
Help : "http://www.gotdotnet.com/team/fxcop/docs/rules.aspx?version=1.312&&url=/Design/StaticHolderTypesShouldNotHaveConstructors.html" (String)
Category : "Microsoft.Design" (String)
CheckId : "CA1053" (String)
RuleFile : "Design Rules" (String)
Info : "Instances of types that define only static members
do not need to be created. Many compilers will automatically
add a public default constructor if no constructor
is specified. To prevent this, adding an empty private
constructor may be required."
Created : "2/26/2005 2:45:41 PM" (DateTime)
LastSeen : "2/26/2005 5:12:46 PM" (DateTime)
Status : Active (MessageStatus)
Fix Category : Breaking (FixCategories)
}

Friday, February 25, 2005

Logging Table

the follwing fields should be included in your Logging table structure.

ID
Datetime
Thread
Level (Info, Error, etc)
Logger
Message
Exception

NUnit: Suites & Categories

using NUnit.Framework;
using NUnit.Core; // requieres nunit.core.dll

[TestFixture]
public class TestClassSuite
{
[Suite]
public static TestSuite Suite
{
get{
TestSuite suite = new TestSuite(@"Give it a name");
suite.Add(new Test1());
suite.Add(new Test2());
// add more test cases
return suite;
}
}
}

The classes you add to the suite (Test1 , Test2 and so on), are marked as [TestFuxuture] classes. Within each of these classes you still have the [Test] attribute on individual mehtods, and the framework will run those automaitcally. The suite facility doesn't stop you running the individual fixtures when you want. But they also let you group those fixtures: by running the one Suite(), you can now run a whole bunch of test fuxtures at once.

suites are a useful machanism for composing tests hierachically, which can be handy for coordinating sets of tests especially for an unattended build.

But it's not that useful a mechanism for day-to-day testing. You would like to be able to cross-cut across all the tests and select or exclude certain kinds of tsests from the vast pool of existing test you have written.

NUnit forces also another mechanism you can use to categroize ansd classify individual test methods and fixtures.

Categories

For instance, suppose you have got a few methods that only take a few seconds to run, but one method that takes a long time to run. You can annotate them using the category attribute.


using NUnit.Framework;
using NUnit.Core;

[TestFixture]
public class SampleCategory()
{
[Test]
[Category("ShortTest")]
public void TestMethod1()
{
// suppose this takes 1 min.
}

[Test]
[Category("ShortTest")]
public void TestMethod1()
{
// suppose this takes 1 min.
}

[Test]
[Category("ShortIntensiv")]
public void TestMethod3()
{
// suppose this takes 3 hours.
}
}

isn't it great . . . . . .

Tuesday, February 22, 2005

NUnit: Restores a DataBase backup

#region Method: RestoreDatabaseBackup
///


/// Restores a DataBase backup
///

///
/// The Database restore operation will be done using a stored procedure called
/// dnx_unittest_restoredatabasebackup
/// That should have as code:
///
/// use Master
/// RESTORE DATABASE Northwind
/// FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\NorthwindBk'
///

///

public virtual void RestoreDatabaseBackup(string database, string backupFilePath)
{
//Dnx.DnxDataLayer.DbBase dbBase = new Dnx.DnxDataLayer.DbBase(this.AuthenticationContext);
this.AuthenticationContext.TransactionManager.OpenConnection();

IDbCommand cmd = this.AuthenticationContext.TransactionManager.Connection.CreateCommand();

try
{
cmd.CommandTimeout = 180;
cmd.CommandText =
string.Format(@"USE MASTER;RESTORE DATABASE {0} FROM DISK = '{1}';", database, backupFilePath);
cmd.ExecuteNonQuery();
}
finally
{
this.AuthenticationContext.TransactionManager.CloseConnection();
}
}
#endregion

Friday, February 04, 2005


make it with clr profiling Part 3 Posted by Hello


make it with clr profiling Part 2 Posted by Hello


make it with clr profiling Part 1 Posted by Hello

Thursday, February 03, 2005


quit lot of snow Posted by Hello

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge