public void DuplicateKeyType() { var instance = new DuplicateKeyType(); Exception expectedException = null; try { MobileServiceTableSerializer.Serialize(instance); } catch (InvalidOperationException exception) { expectedException = exception; } Assert.IsNotNull(expectedException); Assert.AreEqual(expectedException.Message, "Two or more members of type 'DuplicateKeyType' are mapped to the same name 'ColorId'. Verify that your DataMember annotations are correct."); }