ArgsTests.BasicTests.TestManualReviverRegistration C# (CSharp) Метод

TestManualReviverRegistration() приватный Метод

private TestManualReviverRegistration ( ) : void
Результат void
        public void TestManualReviverRegistration()
        {
            // A little bit of reflection magic to ensure that no other test has registered this reviver
            var reviverType = (from a in typeof(Args).Assembly.GetTypes() where a.Name == "ArgRevivers" select a).Single();
            var prop = reviverType.GetProperty("Revivers", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
            var reviverDictionary = prop.GetValue(null,null) as Dictionary<Type, Func<string, string, object>>;
            reviverDictionary.Remove(typeof(MailAddress));

            try
            {
                var parsed = Args.Parse<ArgsThatNeedManualReviverRegistration>("-a", "[email protected]");
                Assert.Fail("The first parse atttempt should have failed.");
            }
            catch (InvalidArgDefinitionException)
            {
                Args.SearchAssemblyForRevivers();
                var parsed = Args.Parse<ArgsThatNeedManualReviverRegistration>("-a", "[email protected]");
                Assert.AreEqual("[email protected]", parsed.Address.Address);
            }
        }