fuzzelogic Solutions

February 8, 2010

Auto mocking coolness

Filed under: BDD, OO, Programming, c#, design — Tags: , , , — admin @ 5:57 pm

Hi! All

Say a big thank you to the structure map guys :- the dependency injection framework with a bit more. It now has Auto mocking. This is great for removing the chattiness of creating mocks for your test classes, and becuase it can use the Rhino AAA style you can don’t have to explicitly define your expectations. :-)

Assume you have a the following class

public class LicenseCatalog {
// this has a dependency on an ILicenseRepository implementation
    public LicenseCatalog (ILicenseRepository repository, ILicenseUpdater updater) {
//….
}
}

Here’s a test using it..

public abstract class get_the_licenseFeature: is_a_feature_provided_by<ILicenseCatalog>{
        [Scenario][Category("in_a_scenario_where<we_get_the_license_file>")]
        public class if_the_settings_file_has_all_the_settings: in_a_scenario_where<we_get_the_license_file>{

            [Observation]
            public void it_should_tell_the_repository_to_load_the_license_file_and_update_the_license(){
                If(x => x.settings_file = new Settings(){hidden_file_name = "hidden", license_file_name = "license"})
                    .when_you_tell(x => x.the_system_under_test.get_license())
                    .observer_that(x => x.repository.was_told_to(r => r.get_license()))
                    .And (x=>x.updater.was_told_to(u=>u.update_license_file());
            }
        }

        public class we_get_the_license_file : baseContext {
            public Settings settings_file;
        }

        public class baseContext : get_the_licenseFeature{
            <strong>RhinoAutoMocker<LicenseCatalog> mocker = new RhinoAutoMocker<LicenseCatalog>();</strong>
            public ILicenseRepository repository;
            public ILicenseUpdater updater;

           protected override ILicenseCatalog create_the_system_undertest(){
// Here we can get the auto mocked dependency back.
                repository = mocker.Get<ILicenseRepository>();
                updater = mocker.Get<ILicenseUpdater>();
                return mocker.ClassUnderTest;
            }
        }
    }

So far it seems great. I don’t have to explicitly mock out the dependencies, and I can only get the ones that used in this test. Its still a little work (but less) so I’m sure its a step in the right direction.
Hope this helps
Thanks
Zak

Skanco -Congratulations.

Filed under: c# — Tags: , , — admin @ 4:42 pm

Hi All!

Following on from the Windows 7 Launch - Skanco are putting together another event to celebrate their authorization as APPLE dealers. Congratualtions to Skanco.

Here’s the note from Skanco. If you having trouble getting a ticket, drop me an email, and I’ll try to get one sorted out for your.

Skanco Business Systems Ltd announce Apple authorisation

IT reseller Skanco celebrated the start of its 25th year by announcing their authorisation to supply Apple products on Friday.  

This new addition to their current range of accreditations gives Skanco further scope to provide professional IT services through their partnerships and truly stand out as one of the leading names in IT on the Island.

David Butterworth Managing Director of Skanco commented “this exciting new partnership enables us to offer Apple as a business solution to our clients; a service which hasn’t been present on the Island until now”

In the same weeks as announcing All-Time Highest Revenue and Profit Steve Jobs Co-founder of Apple also unveiled the new, highly anticipated iPad.  Skanco expect to be the first company on the island to give clients the opportunity to see this innovative product in action.

Currently the biggest user of Apple on the Island are our schools; with all 35 of the Island’s primary schools equipped with over 4000 Mac computers. Skanco will be inviting schools and IT faculty to an education seminar where Apple products will be demonstrated and discussed.

To officially launch the business Apple products on the Island, Skanco have invited representatives from Apple to the Island to host a professional breakfast morning to present and demonstrate their products at the Palace Cinema on the 12th March.  To reserve a place please email your name, company and contact details to apple@skanco.co.uk or call the sales team on 680828.  

The full range of Apple products (excluding the iPhone ) is now available from Skanco whether you are a business or personal user. For  further details on Apple’s business and personal products please visit the Apple Store website (www.apple.com/uk).

January 31, 2010

IOM developers : 1st meeting of 2010

Filed under: c# — admin @ 3:18 pm

Hi!

Sorry for the delay on this one. As you all know, Don Robins was kind enough to share his thoughts and design decisions on a pretty interesting project that highlighted a layered architecture.

It was interesting to see the similarities and differences in design and implementation and also usage of the microsoft MVC framework. He talked us through some on the key layers and the reason for them existing, the benefits and hurdles they present.

Here’s the charted layers.

All the layers

all the layers!!

I’d like to thank Don for taking the time off his really busy schedule to talk this through with us.

I’ll keep you posted on the next one. Can you please let me know date preferences?
Hope this helps.
Thanks
Zak

January 17, 2010

IOM Dev group : 2010 - first meeting.

Filed under: c# — admin @ 2:23 pm

Hey all!

As agreed, first meeting for 2010 - Tuesday 19th at 6 for 6:30. We’re having a great kick off to the year, with Don Robins giving a talk on Layered architecture.

I hope that everyone can make it, and if you need more info, please let me know : email me

Thanks

Zak

January 13, 2010

msbuild

Filed under: c# — Tags: , — admin @ 3:50 pm

Hey all!
MSBuild is the build tool from Microsoft, and ships with the .net framework. Its got the advantage of having a decent build tool thats available on your dev, build, test and production server. This means that your build machine does not need the IDE installed (or anything else). Its XML based, and works by focusing on a Target which runs Task(s). There’s a bunch of predefined tasks, and its “pluggable”, so you can create tasks to do just about anything you want. Each target has a name, and a depends on targets attribute. The name attribute, well that’s easy enough. The dependsOnTargets attribute is a list of other targets that have to happen first, before “this” target runs its task(s).
Here’s a sample msbuild script. I’ve used this as a start off script for a couple projects.

<Project ToolsVersion="3.5"  DefaultTargets="default_build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="nUnitTask"   AssemblyFile="..\lib\Fuzzelogic.MsBuild.Tools.nUnit.dll" />
  <PropertyGroup>
   <Configuration>Debug</Configuration>
    <nUnitConsolePath>..\tools\NUnit 2.5\bin\net-2.0</nUnitConsolePath>
    <BuildLogDirectory>build_log</BuildLogDirectory>
  </PropertyGroup>
  <ItemGroup>
    <ProjectFiles Include="..\**\*.csproj" />
    <TestProjects Include=".\..\**\bin\debug\*tests*.dll" />
  </ItemGroup>

  <Target Name="default_build"
              DependsOnTargets= "run_the_unit_tests"/>

  <Target Name="first_clean_up">
    <MSBuild Projects="@(ProjectFiles)" ContinueOnError="false" Targets="Clean"
                  />

    <RemoveDir Directories="$(BuildLogDirectory)"/>
  </Target>

  <Target Name="first_create_directories"
              DependsOnTargets="first_clean_up">

    <MakeDir Directories="$(BuildLogDirectory)"></MakeDir>
  </Target>

  <Target Name="first_build_the_project_files"
              DependsOnTargets="first_create_directories">

    <MSBuild Projects="@(ProjectFiles)" Targets="Rebuild" ContinueOnError="false"
             >

      <Output TaskParameter="TargetOutputs"     ItemName="BuildOutput"/>
    </MSBuild>
  </Target>

  <Target Name="run_the_unit_tests"
              DependsOnTargets="first_build_the_project_files">

    <CreateItem Include="@(TestProjects)" >
      <Output TaskParameter="Include" ItemName="TestAssemblies" />
    </CreateItem>
    <nUnitTask ConsolePath="$(nUnitConsolePath)"
                   TestAssemblies="@(TestAssemblies)"
                   LogFile="$(BuildLogDirectory)\nunit.logfile"/>

  </Target>
</Project>

For the above to work, I use a folder structure as follows…

solution folder structure

solution folder structure

The build folder contains the build file, lib contains all 3rd party dlls, src(source) contains the source projects, tools contains the 3rd party tools used (nunit, etc).
The build folder also contains a batch/short cut to open a command prompt with the VS Tools assigned. Create a batch file (or short cut and in the target property) add   %comspec% /k “”c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat”" x86 .

 

 

 

 

solution folder structure
biuld folder

Unfortunetly, nUnit tasks are not supported out the box. BUT… hey, its easy to get a task to support the nUnit-console. That’s what the
<UsingTask TaskName=”nUnitTask” AssemblyFile=”..\lib\Fuzzelogic.MsBuild.Tools.nUnit.dll” />
line is using (available here.) There’s also the community tasks project, which has a a bunch more (including the nunit task)

Hope that helps!

Thanx
Zak

« Newer PostsOlder Posts »

Powered by WordPress