f = Encoding.UTF8.DecoderFallback as DecoderReplacementFallback;
Assert.IsNotNull (f, "#5");
- Assert.AreEqual (String.Empty, f.DefaultString, "#6");
- Assert.AreEqual (0, f.MaxCharCount, "#7");
+ // This behavior was introduced as
+ // http://support.microsoft.com/kb/940521/
+ Assert.AreEqual ("\uFFFD", f.DefaultString, "#6");
+ Assert.AreEqual (1, f.MaxCharCount, "#7");
// after beta2 this test became invalid.
//f = new MyEncoding ().DecoderFallback as DecoderReplacementFallback;
}
[Test]
- [ExpectedException (typeof (InvalidOperationException))]
public void DontChangeReadOnlyCodePageDecoderFallback ()
{
- Encoding.GetEncoding (932).DecoderFallback =
- new DecoderReplacementFallback ();
+ Encoding encoding = Encoding.GetEncoding (Encoding.Default.CodePage);
+ try {
+ encoding.DecoderFallback = new DecoderReplacementFallback ();
+ Assert.Fail ("#1");
+ } catch (InvalidOperationException ex) {
+ Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ }
}
[Test]