It is often difficult to assign values one by one when testing the underlying method of an object. It is quite useful to find the serialized XML method on the Internet.
When the front-end calls a method, It serializes the object into an XML file.
// XML Path
StringFilepath =@"D: \ 1.xml";Using(System. Io. streamwriter writer =NewSystem. Io. streamwriter (filepath) {// fileinfo is the object name
System. xml. serialization. xmlserializer XS=NewSystem. xml. serialization. xmlserializer (fileinfo. GetType (); Xs. serialize (writer, fileinfo); writer. Close ();}
Obtain the object by reading XML when testing the underlying method
// XML Path
String Filepath = @" D: \ 1.xml " ; If (System. Io. file. exists (filepath )){ Using (System. Io. streamreader reader = New System. Io. streamreader (filepath) {// fileinfo is the name of the object to be tested.
System. xml. serialization. xmlserializer XS = New System. xml. serialization. xmlserializer (fileinfo. GetType ()); Object OBJ = Xs. deserialize (Reader); reader. Close (); // fileinfo_logistic_entity indicates the object type to be tested.
Fileinfo = OBJ As Fileinfo_logistic_entity ;}}
Serialization Method for Testing