unit test fails in r# but passes in mstest

落爺英雄遲暮 提交于 2019-12-24 08:56:47

问题


I'm getting the error below when running Unit Tests in R#, but the tests pass as expected in Visual Studio MSTest, this is occurring with anything that touches the entity framework, other tests work without a problem, i thought this was because a dll was not deployed but made sure that all the dll's are marked as deploy local = true, also made sure that profiling is turned off as I read that this might cause issues with R#, the exception is pretty strange, can't really find any rhyme or reason on why this would be happening. The code executes without a problem as well, so it is really telling me that something is not ok with R# or my configuration of it. Unfortunately, I've tried everything in the MSTest screen in R# with no luck, even using "Run tests with MSTests.exe (not recommended)" and still all tests fail, but only when they deal with the entity framework. Otherwise they will work without a problem. This is happening in other colleagues systems, so it is not my system only.

Test method Calamos.Ccs.Research.Repository.Test.DatabaseContext.EntityFrameworkContexts.ResearchContext

Test.TestFactorPeriod threw exception: System.InvalidOperationException: The ForeignKeyAttribute on property 'CountryId' on type 'Calamos.Ccs.Research.Business.Oltp.Geographic.Exchange' is not valid. The navigation property 'Country' was not found on the dependent type 'Calamos.Ccs.Research.Business.Oltp.Geographic.Exchange'. The Name value should be a valid navigation property name. at System.Data.Entity.ModelConfiguration.Conventions.ForeignKeyPrimitivePropertyAttributeConvention.ForeignKeyAttributeConventionImpl.ApplyNavigationProperty(PropertyInfo propertyInfo, ModelConfiguration modelConfiguration, ForeignKeyAttribute foreignKeyAttribute) at System.Data.Entity.ModelConfiguration.Conventions.ForeignKeyPrimitivePropertyAttributeConvention.ForeignKeyAttributeConventionImpl.Apply(PropertyInfo propertyInfo, ModelConfiguration modelConfiguration, ForeignKeyAttribute foreignKeyAttribute) at System.Data.Entity.ModelConfiguration.Conventions.AttributeConfigurationConvention3.System.Data.Entity.ModelConfiguration.Conventions.IConfigurationConvention<TMemberInfo,TConfiguration>.Apply(TMemberInfo memberInfo, Func1 configuration) at System.Data.Entity.ModelConfiguration.Conventions.ForeignKeyPrimitivePropertyAttributeConvention.System.Data.Entity.ModelConfiguration.Conventions.IConfigurationConvention.Apply(PropertyInfo memberInfo, Func1 configuration) at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyPropertyConfiguration(PropertyInfo propertyInfo, ModelConfiguration modelConfiguration) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type, ICollection1 annotations, Action2 propertyMappingAction, Boolean mapDeclaredPropertiesOnly, Func1 structuralTypeConfiguration) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type) at System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func1 entityTypeConfiguration, Type sourceType) at System.Data.Entity.ModelConfiguration.Mappers.PropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func1 entityTypeConfiguration, Type sourceType) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.<>c_DisplayClass12.b_e(PropertyMapper m, PropertyInfo p) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type, ICollection1 annotations, Action2 propertyMappingAction, Boolean mapDeclaredPropertiesOnly, Func1 structuralTypeConfiguration) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type) at System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func1 entityTypeConfiguration, Type sourceType) at System.Data.Entity.ModelConfiguration.Mappers.PropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func1 entityTypeConfiguration, Type sourceType) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.<>c__DisplayClass12.<MapEntityType>b__e(PropertyMapper m, PropertyInfo p) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type, ICollection1 annotations, Action2 propertyMappingAction, Boolean mapDeclaredPropertiesOnly, Func1 structuralTypeConfiguration) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type) at System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func1 entityTypeConfiguration, Type sourceType) at System.Data.Entity.ModelConfiguration.Mappers.PropertyMapper.Map(PropertyInfo propertyInfo, EdmEntityType entityType, Func1 entityTypeConfiguration, Type sourceType) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.<>c_DisplayClass12.b_e(PropertyMapper m, PropertyInfo p) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type, ICollection1 annotations, Action2 propertyMappingAction, Boolean mapDeclaredPropertiesOnly, Func1 structuralTypeConfiguration) at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type) at System.Data.Entity.DbModelBuilder.<>c__DisplayClass7.<MapTypes>b__1(Type type) at System.Linq.Enumerable.WhereListIterator1.MoveNext() at System.Data.Entity.ModelConfiguration.Utilities.IEnumerableExtensions.Each(IEnumerable1 ts, Action1 action) at System.Data.Entity.DbModelBuilder.MapTypes(EdmModel model) at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy2.GetValue(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext() at System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider() at System.Linq.Queryable.FirstOrDefault(IQueryable1 source, Expression1 predicate) at Calamos.Ccs.Research.Repository.Test.DatabaseContext.EntityFrameworkContexts.ResearchContextTest.TestFactorPeriod()in ResearchContextTest.cs: line 290

来源:https://stackoverflow.com/questions/11768433/unit-test-fails-in-r-but-passes-in-mstest

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!