Tag: Nuget


I got a short break for some BDD play time this afternoon, so I finally fork JP’s repository, did a git clone, then try to follow his instruction for how to build.

A minor issue encountered, ICreateDelegatesThatThrowExceptions is missing, seems only one method needed there, so I created it manually, build passed.

Quickly convert one of my old test to new BDD style, worked like a charm as it promised.

   public class OrderTranslatorSpecs
        public class When_translate_NHibernate_model_to_csla_bo : Observes<OrderTranslator>
            static Order result;

            Because b = () =>
                    var orderModel = new OrderModel
                                             CustomerName = "A customer"
                    orderModel.AddLineItem(new LineItemModel { Name = "Linteitme1" });

                    result = sut.From(orderModel);

            It should_return_valid_csla_bo = () =>
                    result.CustomerName.ShouldEqual("A customer");

Some nice feature comparing to the classci MachineSpecification framework:

  1. sut (system under test) is created automatically, it can also be overrode by sut_factory.create_using() syntax.
  2. Exception assertion is simple, spec.catch_exception in because block, then do check in it block: spec.exception_thrown.ShouldBeAn<ArgumentException>()
  3. All kinds of adapters to different mock libraries.
  4. mocking is done by fake setup in establish block. mock/fake can happen on a non-interfaced property, including static class, fake auto-rest after test. see example here.

Other cool stuff from JP’s project structure,

  1. By using the default folder created by NuGet, the old centralized lib folder is not split into each package’s own lib folder.
  2. MSBuild is called by rake, instead of nant, it saved a lot of time by not doing nant include/exclude file organizing work.
  3. Ruby/Rake build is clean and powerful!

Ninject auto binding

This is called scan by convention in StructureMap, I’m surprised it’s not in standard Ninject package, while this feature call be found in Ninject.extension.conventions.

OK, let go get it. git clone, compile failed due to whole bunch of silverlight stuff. Weird, I gave up, time to try the powerful NuGet.

I would say NuGet is amazing, dependency lookup just like gem in ruby, libs are downloaded into packages folder.? OK, anyway, move it after if you don’t like it.

How to get the history version from NuGet?

One frustrated thing in VisualStduio is, the version number in project file (csproj) still keeps untouched, the problem turned to compile passed, but unit-test running into an error, can not find the assembly in old version.

Old version is not in GAC, I had to change those out-of-date csproj manually, the problem went away. VisualStudio Bug?

Ninject auto binding code:

            var standardKernel = new StandardKernel();

            // Manually set bind for those classes not folowing convention

            standardKernel.Scan(x =>

About generic:

For closing generic implementation like EmailRepository : IRepository<Email>, we can use

a.BindWith(new GenericBindingGenerator(typeof(IRepsitory<>)));

Even more advanced, checkĀ  this post about multi generic binding.

For open generic (Jeremy Miller is not recommanding this approach though.) like Repository<Email> : IRepository<Email>, the trick is: