Created
November 8, 2012 22:59
-
-
Save rofr/4042429 to your computer and use it in GitHub Desktop.
protobuf-net failing test case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
protobuf-net failing test case. This has got to be a bug! | |
*/ | |
[TestMethod] | |
public void IsDefined_on_empty_model_should_return_false() | |
{ | |
var typeModel = RuntimeTypeModel.Create(); | |
//See definition of FailingType below! | |
Assert.IsFalse(typeModel.IsDefined(typeof(FailingType))); | |
} | |
// The documentation for IsDefined "Indicates whether the supplied type is explicitly modelled by the model" | |
// In addition to returning the wrong answer, the type is added to the model | |
// IsDefined is a query, yet mutates the state of the RuntimeTypeModel instance. This is a violation of the CQS principle. | |
/// <summary> | |
/// Any class with public readonly fields and a public constructor | |
/// with parameters with matching and names! | |
/// </summary> | |
class FailingType | |
{ | |
public readonly int MyField; | |
public readonly string MyField2; | |
public FailingType(int myField, string myField2) | |
{ | |
MyField = myField; | |
MyField2 = myField2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment