public void UnpackV1Test(int packed, int episode, int release) { var unpacked = PackedId.Unpack(packed); Assert.AreEqual(1, unpacked.Version, "Version is wrong"); Assert.AreEqual(episode, unpacked.EpisodeId, "Episode is wrong"); Assert.AreEqual(release, unpacked.ReleaseId, "Release is wrong"); }
public void RoundRobinTest() { var rnd = new Random(); for (int i = 0; i < 100; i++) { var source = rnd.Next(int.MinValue, int.MaxValue); var p1 = PackedId.Unpack(source); var p2 = new PackedId(p1.ReleaseId, p1.EpisodeId); if (p1.Version == 0) { var boxed = (object)p2; typeof(PackedId).GetField(nameof(p2.Version), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).SetValue(boxed, 0); p2 = (PackedId)boxed; } Assert.AreEqual(source, p1.Pack(), "Round-robin 1st iteration didn't work for " + source); Assert.AreEqual(p1.Version, p2.Version, "Version wrong"); Assert.AreEqual(p1.EpisodeId, p2.EpisodeId, "EpisodeId wrong"); Assert.AreEqual(p1.ReleaseId, p2.ReleaseId, "ReleaseId wrong"); Assert.AreEqual(source, p2.Pack(), "Round-robin 2rd iteration didn't work for " + source); } }