Wednesday, June 10, 2009

Enabling Sitecore CMS6 logging in tests

I ran into an issue when writing unit tests code that used the Sitecore CMS6 Sitecore.Disagnostics.Log class. My App.config had a log4net section but nothing was being logged to the appenders.
Using reflector I found out the Sitecore.Diagnostics.Log.Enabled returns Sitecore.Configuration.Settings.ConfigurationIsSet. So I added the configSection:

<section name="sitecore" type="Sitecore.Configuration.ConfigReader, Sitecore.Kernel" />

and a stub sitecore section to get things working.

Tuesday, June 9, 2009

SettingsPropertyValue.PropertyValue throws a NullReferenceException

    SettingsPropertyValue settingsPropertyValue = new SettingsPropertyValue(settingsProperty);
    settingsProperty.PropertyType = typeof(string); //Must set the type to use the PropertyValue
    settingsPropertyValue.PropertyValue = "FooBar";
    Assert.AreEqual("FooBar", settingsPropertyValue.PropertyValue);

If the SettingsProperty.PropertyType isn't set you will get a NullReferenceException when trying to access the PropertyValue.

See Also: Profile Provider Exception

Friday, June 5, 2009

Nelson .NET User Group Presentation - ASP.NET MVC - 24th of June

Upcoming presentation

Owen Evans will be giving a presentation on Wednesday the 24th of June.

Title:
ASP.NET MVC

Abstract:
This is TBC. In general it will be covering -

  • What is MVC?
  • What is the ASP.NET MVC Framework?
  • How to get started in MVC?
  • What are the main concerns moving from WebForms to MVC?
  • Will MVC suit me?
  • Q&A?

Useful links:

When:
Wednesday 24th June 2009
Gather at 11:50 am, starting at 12:00 pm.
Approximately 1 hour plus pizza afterward.

Where:
FuseIT Ltd,
Ground Floor,
7 Forests Rd,
Stoke,
Nelson
(Off Nayland Rd and behind Carters)

http://local.live.com/default.aspx?v=2&cp=-41.299774~173.236231&style=r&lvl=16&alt=-1000
or
http://maps.google.com/?ie=UTF8&om=1&z=17&ll=-41.299774,173.236231&spn=0.005239,0.010042&t=h

If you are parking on site, please use the parks marked FuseIT that are at the back of the site.

Giveaways:
A Windows Game

Catering: Pizza & Drinks
Door Charge: Free

RSVP to me if you are going to attend so I can guesstimate the food and drink requirements.

However, feel free to turn up on the day though if you can't commit at the moment.

Please feel free to invite anyone who may be interested in attending.

Enabling code coverage in Visual Studio 2008 - "Code Coverage is not enabled for this test run"

After right clicking on a Test Result and selecting "Code Coverage Results" I'm taken to the Code Coverage Results area and shown the message "Code Coverage is not enabled for this test run". To enable it:

  • Test > Edit Test Run Configurations > Local Test Run (...)
  • Code Coverage
  • Check the artifacts/DLLs that you want to see code coverage for.

If you get the message "Code coverage instrumentation warning while processing file FooBar.dll:
Warning VSP2013 : Instrumenting this image requires it to run as a 32-bit process. The CLR header flags have been updated to reflect this." try unchecking Instrument assemblies in place

See also: Code Coverage is not enabled for this test run
TESTTOOLSTASK : warning VSP1024: Unable to open file 'file' for writing.

Friday, May 22, 2009