Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Dec 10, 2021
1 parent 0114269 commit 7d70c89
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ public void CampaignDescriptor_Test()
var hero = (Hero) FormatterServices.GetUninitializedObject(typeof(Hero));
#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159
AccessTools.Field(typeof(Hero), "Name").SetValue(hero, new TextObject("TestHero"));
#elif e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#elif e1510 || e160 || e161 || e162 || e163 || e164 || e165
AccessTools.Property(typeof(Hero), "Name").SetValue(hero, new TextObject("TestHero"));
#elif e170
AccessTools.Field(typeof(Hero), "_name").SetValue(hero, new TextObject("TestHero"));
#else
#error ConstGameVersionWithPrefix is not handled!
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,22 @@ public void CheckForUnsupportedSaveableClassTypes_Test()
var saveableClassTypes = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a =>
{
IEnumerable<Type> Filter(Type[] types)
IEnumerable<Type> Filter(IEnumerable<Type> types)
{
return types.Where(t => t is not null && !t.IsAbstract && !t.IsGenericType &&
t.GetMembers().Any(m => m.GetCustomAttributes(true).Any(
att => att.GetType() == typeof(SaveableFieldAttribute) ||
att.GetType() == typeof(SaveablePropertyAttribute))));
return types.Where(t =>
{
try
{
return t is not null && !t.IsAbstract && !t.IsGenericType &&
t.GetMembers().Any(m => m.GetCustomAttributes(true).Any(
att => att.GetType() == typeof(SaveableFieldAttribute) ||
att.GetType() == typeof(SaveablePropertyAttribute)));
}
catch (FileNotFoundException e)
{
return false;
}
});
}
try
{
Expand Down Expand Up @@ -123,10 +133,20 @@ public void CheckForUnsupportedSaveableMembers_Test()
{
IEnumerable<Type> Filter(Type[] types)
{
return types.Where(t => t is not null && !t.IsAbstract && !t.IsGenericType &&
t.GetMembers().Any(m => m.GetCustomAttributes(true).Any(
att => att.GetType() == typeof(SaveableFieldAttribute) ||
att.GetType() == typeof(SaveablePropertyAttribute))));
return types.Where(t =>
{
try
{
return t is not null && !t.IsAbstract && !t.IsGenericType &&
t.GetMembers().Any(m => m.GetCustomAttributes(true).Any(
att => att.GetType() == typeof(SaveableFieldAttribute) ||
att.GetType() == typeof(SaveablePropertyAttribute)));
}
catch (FileNotFoundException e)
{
return false;
}
});
}
try
{
Expand Down

0 comments on commit 7d70c89

Please sign in to comment.