开发者

Automapper error first time we run Unit Tests with MSTest

We are getting an Automapper error the FIRST time we run our Unit Tests in VS 2008 (MSTest). "Missin开发者_运维知识库g 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;
        }

    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜