RhinoMocks – WhenCalled

The following test would fail without this   .WhenCalled(invocation => invocation.ReturnValue = new TestResult(){IsTrue = true, Message = “BBB”})     using System; using System.Collections.Generic; using System.Linq; using System.Text; using Matlock.Core.Shared; using Microsoft.VisualStudio.TestTools.UnitTesting; using Rhino.Mocks; […]

WPF UI Thread Dispatcher

A simple implemention for calling asych methods from the UI   Examples   1. dispatcher.ExecuteOnMainUIThread(CommandManager.InvalidateRequerySuggested);   2. dispatcher.Execute(() => { SomeLongRunningMethodHere(); });   The interface using System; namespace Mvvm { public interface IDispatcher { void […]

Allow IIS7 to download .config files

1. In the following file C:\Windows\System32\inetsrv\config\applicationHost.config Ensure the following <section name=”requestFiltering” overrideModeDefault=”Allow” /> 2 This is the web.config file   <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <system.webServer> <handlers> <clear /> <add name=”StaticFile” path=”*” verb=”*” modules=”StaticFileModule,DefaultDocumentModule,DirectoryListingModule” resourceType=”Either” requireAccess=”Read” […]

Stream bytes to files

using (var stream = Assembly.GetAssembly(typeof(StubPolicy)).GetManifestResourceStream( “Documents.TestHelpers.Files.test.msg”)) { const int bufferLength = 256; var buffer = new Byte[bufferLength]; if (stream != null) { int bytesRead = stream.Read(buffer, 0, bufferLength); using (var fs = new FileStream(filename, FileMode.CreateNew, […]