繁体   English   中英

第一次我们使用MSTest运行单元测试时出现Automapper错误

[英]Automapper error first time we run Unit Tests with MSTest

第一次在VS 2008(MSTest)中运行单元测试时,我们遇到了Automapper错误。 “缺失型地图配置或不支持的映射。类型的异常‘AutoMapper.AutoMapperMappingException’被抛出”

如果我们重新运行测试(“运行检查的测试”),则它们全部通过。 4个开发人员中只有2个出现此问题。 我们尝试将超时添加到“引导程序”中,但这没有用。 有人遇到这个问题吗?

引导程序代码如下所示:

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;
        }

    }
}

找出解决方案。 我们在那里没有设置IsConfigured为false,每个单元测试(杜)。 仍然不确定为什么它可以在某些机器上运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM