Tag Archive for 'R#'

NUnit introduces the concept of row tests

Latest version of NUnit unit-testing framework for .NET has finally got support for the row tests. They are implemented by Andreas Schlapsi as an extension that now comes bundled with the NUnit 2.4.7.

Basically, row test is a test that could be run multiple times with different parameters (in other words, it is a simple data-driven test, where the data is provided by the attributes). Consider the following C# code snippet:

[TestFixture]
public sealed class Test_InterceptorCompiler : DslTests
{
	[RowTest]
	[Row("Chained Interceptions.boo")]
	[Row("ConsoleWriter.boo")]
	[Row("IWriter.boo")]
	[Row("Multiple Classes.boo")]
	[Row("Complex Writer.boo")]
	public void Interception_Dsl_Compiles(string name)
	{
		var step = new InterceptorCompilerStep()
			.Intercept<ComplexWriter>()
			.Intercept<ConsoleWriter>()
			.Intercept<IWriter>();

		CompileDslToMemory(step, name);
	}
}

Upon the execution in the NUnit GUI it will produce the following output:

Row tests in NUnit

Note, how every Row is treated as a separate unit test, and you can see which parameters have caused the failure.

Disadvantage of this new feature of NUnit is - JetBrains test runner (it comes with the R#) does not recognize them, yet. You would need to fire up NUnit GUI or use some other VS integration like TestDriven.NET in order to “run this test from the code”.

PS: there is an interesting podcast on the topic - The Past, Present and Future of .NET Unit Testing Frameworks.

Some more new ReSharper 4.0 features

Here are some other “minor” features (support for the new C# syntax and Linq being the major feature for me) that I really like in the new ReSharper 4.0:

  • New capital letter completion in R# (i.e.: typing CCM in R# Type Navigaton instantly brings you ClientCoreModule). This type of completion still feels a bit weird but it just works for me.
  • Solution-wide analysis (like background compilation in VB)
  • Support for custom file headers (adding and updating all these copyrights)
  • R# code annotations for the BCL (although I still haven’t tried to annotate my own classes). I can see Spec# type of functionality probably coming out of this in the future.

BTW, letter auto-completion works in Launchy as well. For example: typing MVS will bring Microsoft Visual Studio.

Just do not leave R# 4.0 EAP home alone.

R# 4.0 EAP is the best thing that we can have right now, but you’ve got to be really careful about it. Especially, if you have habit of keeping your Visual Studio instances running for days, like I do.

Just today my R# finally ate all free space on his hard drive with logs (7 GBs) then threw an exception in all 3 VS 2008 instances. As if it was not enough, all VS instances crashed after that.

How to use ORM (XPO), IoC, C# 3.5 syntax, Linq and .NET 2.0 together?

One of the most important features of any proper development architecture, environment or process, is that the synergy (network) effects accumulate, if you keep doing the right things. IoC/DI, unit testing and TDD, continuous integration - all these just form up the external side of how everything works. They simply help (or force) to shape the logics of the development to make everything fold smoothly and let your solutions accumulate the benefits.

Now, let us get back to the IoC+ORM series and take one more look at the ICommand implementation from the last post. It could be improved quite a bit:

public sealed class DisableAllAccounts : ICommand
{
  private readonly IRepository<Account> _accounts;
  private readonly ILog _log;

  public DisableAllAccounts(IRepository<Account> accounts, ILog log)
  {
    _accounts = accounts;
    _log = log;
  }

  public void Execute()
  {
    _log.Write("Disabling accounts:");
    _accounts.CriteriaString = "Disabled=0";
    foreach (var account in _accounts)
    {
      _log.Write(account.Name);
      account.Disabled = true;
      account.Save();
    }
  }
}

Things become better as we throw out things that do not fit well. So let us remove our custom IRepository<> from this picture (along with the FireCollection behind it) and get rid of the string literal in favor of something that is compiler-checked

Continue reading ‘How to use ORM (XPO), IoC, C# 3.5 syntax, Linq and .NET 2.0 together?’

ReSharper 4.0 EAP - Nightly builds are available for download

You can download nightly builds of ReSharper 4.0 to start working with these features (as quoted from the roadmap):

  • Support for both Visual Studio 2005 and 2008
  • Comprehensive support for C# 3.0 language features, including:
    • New code analysis, context actions and quick-fixes
    • New refactorings (such as Convert to Extension Method, Convert to Automatic Property, Convert Anonymous Type to Named)
    • Updated IntelliSense
  • Many more intelligence and productivity features
    • Full set of refactorings available for VB.NET
    • New quickfixes and context actions for XAML files
    • Referenced assemblies are now taken into account in null-reference analysis thanks to external annotations. ReSharper is packaged with annotations for the .NET Framework assemblies
    • Code Cleanup — a tool for ensuring compliance with code guidelines and enhancing code structure
    • Complete Statement — a feature that will complete language constructs and get you ready to write the next statement
    • Many other enhancements and new features throughout the product

Update: ReSharper 4.0 feels to be a terrific aid in the development (esp. when compared with working on VS 2008 with 3.1). The only decent problem is that the solution-wide analysis marks extension methods as errors if there is no reference to System.Core (i.e.: using LinkBridge.dll to compile towards .NET 2.0). Ilya has created an issue that could be tracked here.

How to improve Resharper performance with big projects

If the Resharper suddenly slows down while you’re working on a big project, try to close all open designer tabs. This always helps me.

eXpressApp Framework and Resharper conflicts

When installed, eXpressApp Framework 7.3.5 brings “DXCore for Visual Studio .NET” along with it.

I didn’t ask for it.

Not only that slows down the Visual Studio 2005 IDE, but also messes up the Resharper integration.

Fortunately the DXCore went away without any problems (XAF installation stayed intact).