views:

64

answers:

1

We are getting an Automapper error the FIRST time we run our Unit Tests in VS 2008 (MSTest). "Missing type map configuration or unsupported mapping. Exception of type 'AutoMapper.AutoMapperMappingException' was thrown"

If we re-run the tests ("Run Checked Tests") then they all pass. Only 2 out of the 4 developers are having this issue. We tried adding a timeout to our "Bootstrapper" but that did not work. Anyone run into this problem?

Bootstrapper code looks like this:

public static class AutoMapperConfiguration
{
    public static bool IsConfigured { get; set; }
    public static bool IsConfiguring { get; set; }

    public static void Configure()
    {
        do
        {
            Thread.Sleep(10);
        } while (IsConfiguring);

        if (!IsConfigured)
        {
            IsConfiguring = true;
            Mapper.Reset();
            Mapper.Initialize(x => x.AddProfile<DataContractProfile>());
            IsConfiguring = false;
            IsConfigured = true;
        }

    }
}
A: 

Figured out the solution. We where not setting IsConfigured to false on each unit test (Duh). Still not sure why it was working on some machines.

Bill Hennell