• <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'>

        测试一个类是否有属性?

        Test if a class has an attribute?(测试一个类是否有属性?)
          <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....)

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

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Accessing attribute info from DTE(从 DTE 访问属性信息)
                  c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  How can I force the PropertyGrid to show a custom dialog for a specific property?(如何强制 PropertyGrid 显示特定属性的自定义对话框?)
                  Associate attribute with code generated property in .net(将属性与 .net 中的代码生成属性相关联)
                    <tbody id='6EZpi'></tbody>

                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'>