• <tfoot id='OlveM'></tfoot>
    <i id='OlveM'><tr id='OlveM'><dt id='OlveM'><q id='OlveM'><span id='OlveM'><b id='OlveM'><form id='OlveM'><ins id='OlveM'></ins><ul id='OlveM'></ul><sub id='OlveM'></sub></form><legend id='OlveM'></legend><bdo id='OlveM'><pre id='OlveM'><center id='OlveM'></center></pre></bdo></b><th id='OlveM'></th></span></q></dt></tr></i><div id='OlveM'><tfoot id='OlveM'></tfoot><dl id='OlveM'><fieldset id='OlveM'></fieldset></dl></div>

      • <bdo id='OlveM'></bdo><ul id='OlveM'></ul>

        <legend id='OlveM'><style id='OlveM'><dir id='OlveM'><q id='OlveM'></q></dir></style></legend>
      1. <small id='OlveM'></small><noframes id='OlveM'>

        测试一个类是否有属性?

        时间:2023-07-27
          <bdo id='zKhia'></bdo><ul id='zKhia'></ul>

        • <tfoot id='zKhia'></tfoot>

          <small id='zKhia'></small><noframes id='zKhia'>

              <tbody id='zKhia'></tbody>

                1. <i id='zKhia'><tr id='zKhia'><dt id='zKhia'><q id='zKhia'><span id='zKhia'><b id='zKhia'><form id='zKhia'><ins id='zKhia'></ins><ul id='zKhia'></ul><sub id='zKhia'></sub></form><legend id='zKhia'></legend><bdo id='zKhia'><pre id='zKhia'><center id='zKhia'></center></pre></bdo></b><th id='zKhia'></th></span></q></dt></tr></i><div id='zKhia'><tfoot id='zKhia'></tfoot><dl id='zKhia'><fieldset id='zKhia'></fieldset></dl></div>
                  <legend id='zKhia'><style id='zKhia'><dir id='zKhia'><q id='zKhia'></q></dir></style></legend>

                  本文介绍了测试一个类是否有属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试进行一些 Test-First 开发,并且正在尝试验证我的类是否标有属性:

                  I'm trying to do a little Test-First development, and I'm trying to verify that my classes are marked with an attribute:

                  [SubControllerActionToViewDataAttribute]
                  public class ScheduleController : Controller
                  

                  我如何对类分配了该属性进行单元测试?

                  How do I unit test that the class has that attribute assigned to it?

                  推荐答案

                  检查一下

                  Attribute.GetCustomAttribute(typeof(ScheduleController),
                      typeof(SubControllerActionToViewDataAttribute))
                  

                  不为空(Assert.IsNotNull 或类似)

                  (我使用它而不是 IsDefined 的原因是大多数时候我也想验证属性的某些属性......)

                  (the reason I use this rather than IsDefined is that most times I want to validate some properties of the attribute too....)

                  这篇关于测试一个类是否有属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:设计时表单的自定义可浏览属性 下一篇:过时的属性导致属性被 XmlSerialization 忽略

                  相关文章

                2. <legend id='6EZpi'><style id='6EZpi'><dir id='6EZpi'><q id='6EZpi'></q></dir></style></legend>

                    <bdo id='6EZpi'></bdo><ul id='6EZpi'></ul>
                    <tfoot id='6EZpi'></tfoot>

                    1. <i id='6EZpi'><tr id='6EZpi'><dt id='6EZpi'><q id='6EZpi'><span id='6EZpi'><b id='6EZpi'><form id='6EZpi'><ins id='6EZpi'></ins><ul id='6EZpi'></ul><sub id='6EZpi'></sub></form><legend id='6EZpi'></legend><bdo id='6EZpi'><pre id='6EZpi'><center id='6EZpi'></center></pre></bdo></b><th id='6EZpi'></th></span></q></dt></tr></i><div id='6EZpi'><tfoot id='6EZpi'></tfoot><dl id='6EZpi'><fieldset id='6EZpi'></fieldset></dl></div>

                      <small id='6EZpi'></small><noframes id='6EZpi'>