Fix RightsHelper.AllRights add test

This commit is contained in:
Jordan Brown
2020-04-09 13:09:13 -04:00
parent 9591ad4964
commit dedf9869ea
2 changed files with 13 additions and 4 deletions
@@ -79,11 +79,11 @@ namespace Tgstation.Server.Api.Rights
public static TRight AllRights<TRight>() where TRight : Enum
{
ulong rights = 0;
Type rightsType = typeof(TRight);
foreach (Enum J in Enum.GetValues(rightsType))
rights = rights | Convert.ToUInt64(J, CultureInfo.InvariantCulture);
foreach (Enum J in Enum.GetValues(typeof(TRight)))
rights |= Convert.ToUInt64(J, CultureInfo.InvariantCulture);
return (TRight)Convert.ChangeType(rights, rightsType, CultureInfo.InvariantCulture);
// cri evertim
return (TRight)(object)rights;
}
}
}
@@ -36,5 +36,14 @@ namespace Tgstation.Server.Api.Rights.Tests
}
}
}
[TestMethod]
public void TestAllRightsWorks()
{
var allByondRights = ByondRights.CancelInstall | ByondRights.ChangeVersion | ByondRights.ListInstalled | ByondRights.ReadActive;
var automaticByondRights = RightsHelper.AllRights<ByondRights>();
Assert.AreEqual(allByondRights, automaticByondRights);
}
}
}