[Theory] [InlineData(10)] public void TestMethod(int value) { XunitSerializationInfo info = new XunitSerializationInfo(); info.AddValue("value", value); int deserializedValue = info.GetValue("value"); Assert.Equal(value, deserializedValue); }
[Theory] [InlineData("hello", 10)] public void TestMethod(string message, int errorCode) { ErrorInfo error = new ErrorInfo(errorCode, message); XunitSerializationInfo info = new XunitSerializationInfo(); info.AddValue("error", error); ErrorInfo deserializedError = info.GetValueIn this example, a test case method is defined with a string and an int parameter. A complex object ErrorInfo is created using these parameters. The object is serialized using XunitSerializationInfo object's AddValue method. The GetValue method is used to retrieve the serialized ErrorInfo object and compare it with the original object using assertions. Package library: The IXunitSerializationInfo interface belongs to the Xunit.Abstractions package library.("error"); Assert.Equal(error.ErrorCode, deserializedError.ErrorCode); Assert.Equal(error.Message, deserializedError.Message); }