title: How to test if method returns expected data type?
body: <p>Is it possible to create a NUnit Test method to check if the method returns the expected data type ?</p>
  
  <p>Here's what I mean:</p>
  
  <p>I've a static string that takes two parameters and checks to see if it matches with another string. If it does the methods simply returns that string.</p>
  
  <p>I want to test to ensure that this method does infact return type of string and any exceptions that might occur.</p>
  
  <p>Sample Code:</p>
  
  <pre><code>public static string GetXmlAttributeValue(this XmlElement element, string attributeName)
      {
          if (element == null)
          {
              throw new ArgumentNullException("element");
          }
  
          if (attributeName == null)
          {
              throw new ArgumentNullException("attributeName");
          }
  
          string attributeValue = string.Empty;
          if (element.HasAttribute(attributeName))
              attributeValue = element.Attributes[attributeName].Value;
          else
              throw new XmlException(element.LocalName + " does not have an attribute called " + attributeName);
          return attributeValue;
      }
  </code></pre>
  
  <p>Here's how my solution is looking:</p>
  
  <p><a href="https://i.stack.imgur.com/jgmXE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jgmXE.png" alt="enter image description here"></a></p>
  
  <p>I'd like to write my test code within the <code>TestLibrary</code> class library.</p>