Exemplo n.º 1
0
 public void TestSetParameter()
 {
     var builder = new MediaTypeBuilder();
       builder.SetParameter("a", "b");
       {
     string stringTemp = builder.ToMediaType().GetParameter("a");
     Assert.AreEqual(
       "b",
       stringTemp);
     }
       builder.SetParameter("a", String.Empty);
       Assert.AreEqual(String.Empty, builder.ToMediaType().GetParameter("a"));
       try {
      builder.SetParameter(null, String.Empty);
     Assert.Fail("Should have failed");
     } catch (ArgumentNullException) {
     new Object();
     } catch (Exception ex) {
      Assert.Fail(ex.ToString());
     throw new InvalidOperationException(String.Empty, ex);
     }
       try {
      builder.SetParameter(String.Empty, null);
     Assert.Fail("Should have failed");
     } catch (ArgumentNullException) {
     new Object();
     } catch (Exception ex) {
      Assert.Fail(ex.ToString());
     throw new InvalidOperationException(String.Empty, ex);
     }
       try {
      builder.SetParameter(String.Empty, "a");
     Assert.Fail("Should have failed");
     } catch (ArgumentException) {
     new Object();
     } catch (Exception ex) {
      Assert.Fail(ex.ToString());
     throw new InvalidOperationException(String.Empty, ex);
     }
       try {
      builder.SetParameter("a\u00e0", "a");
     Assert.Fail("Should have failed");
     } catch (ArgumentException) {
     new Object();
     } catch (Exception ex) {
      Assert.Fail(ex.ToString());
     throw new InvalidOperationException(String.Empty, ex);
     }
 }