Tuesday, March 30, 2010

Test Lint (Beta): Find common problems in your unit test code

http://site.typemock.com/test-lint/

I think it can be interesting for developers who use C# and VS2010:

Writing unit tests is easy. Writing good unit tests – that are readable, maintainable and trust-worthy is a bit harder if you’ve never done it before. So we took Roy Osherove (author of The Art of Unit Testing) and asked him to write down, based on his massive experience with unit testing, common problems that people do when they first start unit testing. Then we put that knowledge inside a Visual Studio 2010 extension– it’s like having your own personal coach letting you know of problems as you type them, really.

Test Lint parses your code as you type it, and looks for common problems in your unit test code – from missing asserts to having tests depend on other tests – Test Lint will notify you on the spot about each possible issue with a visible queue right inside your editor, right next to the link where the issue appears.

Test Lint will detect issues in tests written with:

  • Microsoft Test Framework
  • NUnit
  • MbUnit
  • XUnit.NET
  • CsUnit

Tuesday, March 23, 2010

Move a SharePoint Content Database


It's pretty easy:

Sometimes it's the easy things that are hard to track down concrete instructions for! Here are step by step instructions for moving your MOSS content database to a new server, followed by the things to watch out for.

You have two initial options, doing a backup and restore within MOSS to move the data, or doing it at the SQL/STSADM level. I prefer the latter, as it isn't nearly as inclined to fail and leaves you with more flexibility.

1) Find the content Database

These are listed under Central Admin->Application Management->Site Collection List

2) Backup the content database

You could alternatively detach it, and copy it. Just doing a backup in SQL Server 2005 Management studio is easier.

3) Restore content database to new server

Copy the BAK file to new server. Create an empty DB in Management Studio, restore from backup, you may need to change an option in the "options" tab of the restore dialog to get it to work. (Overwrite db).

4) Create Web App on new Server

Central Admin->Application Management->Create or extend Web App->Create New Web App.

5) Associate restored DB with new Web App

Central Admin->Application Management->SharePoint Web Application Management->Content Databases->

Remove Content Database from your new web app.

Now use STSADM to add restored DB to this web app

c:\program files\common files\microsoft shared\web server extentions\12\bin on new server is where you can find the STSADM.

run this command from there.

stsadm -o addcontentdb -url http://yourwebapp:port -databasename yourcontentdb -databaseserver yoursqlserver

6) Run ISSRESET from command prompt.

Caveats:

  • Make sure your running the same service pack level on both source and destination sharepoint if possible.
  • Make sure you install all webparts, solutions, features, etc on new server before you restore the content database, so that it can find all the features it's looking for.
  • Make sure you copy any files that may be living in the file system that you need, sometimes people have css/javascript here. (This refers to files in the hive)
  • Leave your old site and contentDB intact until you get the backup running on the new server, this way your ok if there is a problem.
  • DON'T try this with your config database! It won't work!

Monday, March 22, 2010

Get all users with Full Control for the web

Instead of user enumeration and check roles for each user, you can get role assignments for web and get all users for corresponding role.

Like this:

using(SPWeb web = SPSite(webUrl).OpenWeb())

{

SPRoleDefinitionCollection roleDefinitions = web.RoleDefinitions;

SPRoleDefinition roleDefinition = roleDefinitions["Full Control"];

foreach (SPRoleAssignment roleAssigment in web.RoleAssignments)

{

if (roleAssigment.RoleDefinitionBindings.Contains(roleDefinition))

{

SPPrincipal oPrincipal = roleAssigment.Member;//it can be SPUser or SPGroup, you can process and add it to the result

}

}

}

MSDN forum

Friday, March 19, 2010

Interview with Uncle Bob Martin (TDD, craftsmanship)

http://blog.typemock.com/2010/03/finally-entire-interview-with-uncle-bob.html

What is software craftsmanship all about?

Why TDD is not stupid

Confessions of a TDDer

TDD and unit testing adoption

Wednesday, March 17, 2010

Import WSS 3.0 Doclib to SharePoint 2010 with Content Migration API

It works.
You need just to change the schema version in SystemData.xml file to new SharePoint 2010 version ("14.0.0.0" Build="14.0.4730.1010" for my lab).

Ghosted vs Unghosted and where the file lives

Ghosted == Uncustomized == lives on the file system

These are generally deployed using features or site definitions


Unghosted == customized == lives in the content databse.

These files are either files that have been modified using SharePoint designer or uploaded through the user interface.

Generally Ghosted/unghosted were the terms used with SP 2003, while customized/uncustomized were introduced with 2007, supposedly to make the terms easier to understand.

http://platinumdogs.wordpress.com/2009/08/13/uncustomized-ghosts-vs-unghosted-customizations/

From MSDN forum: Original thread

Wednesday, March 10, 2010

SPExportSettings.FileMaxSize - limitations

MSDN describes that FileMaxSize allows to set 2GB.
But it looks like that it works with range from 1 to 1023 only, at least it tries to work :)

For any values >= 1024 the export uses default cmp size = 24MB

Also is interesting that stsadm has 1024 as a maximum cabsize value.

FileMaxSize works, at least I can get 10MB package. But the export fails on my lab with FileMaxSize > 100: "FatalError: Export ran out of memory while compressing a very large file. To successfully export, turn compression off by specifying the -nofilecompression parameter."

I have tried to export 6GB site and export works only with FileMaxSize <= 100. I think "100" can depend from real site data size.

There is interesting point that error can be raised due the manifest.xml size. I think that true is somewhere near, because compression works with default size. Probably the compression can not split some long description of object from manifest.xml between several files.
Looks like a bug.

Wednesday, March 3, 2010

SPExportObject.IncludeDescendants vs SPExportObject.ExcludeChildrens, what's the difference?

Really, what's the difference between children and descendants?

MSDN doesn't say about this difference: IncludeDescendants, ExcludeChildren.

But it looks like that IncludeDescendants is more flexible.

Export result shows that:

· ExcludeChildren = true is the same with IncludeDescendants = SPIncludeDescendants.Content.

· ExcludeChildren = false goes to IncludeDescendants = SPIncludeDescendants.All.

Ok, let check how the export depends from IncludeDescendants value and ExportObject type.

SPDeploymentObjectType.Web:

SPIncludeDescendants.All all web content and its sub-containers (like doclibs and lists) with sub-sites is exported

SPIncludeDescendants.Content – only root web content (doclibs, lists) is exported, without sub-sites

SPIncludeDescendants.None – exports only web property and service containers (like galleries). Usual doclibs and lists are not exported. In this mode export result doesn’t contain any custom aspx files from root web folder. /_themes, /images subfolders are excluded from the export also.

SPDeploymentObjectType.List

SPIncludeDescendants.Content, SPIncludeDescendants.All – full list content is exported

SPIncludeDescendants.None – only list properties are exported, no content

ExcludeChildren – doesn’t work for List because it maps to SPIncludeDescendants.Content or SPIncludeDescendants.All, those have the same export result. Note: MSDN says that ExcludeChildren works for List, but I do not see difference between results for ExcludeChildren = true or false. But it works for Folder!

SPDeploymentObjectType.Folder

SPIncludeDescendants.All (or ExcludeChildren = false) full folder and its sub-folders content is exported

SPIncludeDescendants.Content (or ExcludeChildren = true) and None – only folder properties is exported!

Tuesday, March 2, 2010

About SharePoint limitations

For URLs (by Joel)

For item&doc count (by Keith)

It was pretty easy.

I didn't think that blog creation is very easy. But it's true.