You've already forked linux-packaging-mono
311 lines
13 KiB
C#
311 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Runtime.Serialization;
|
|
using System.ServiceModel;
|
|
using System.ServiceModel.Channels;
|
|
using System.ServiceModel.Description;
|
|
using System.Xml;
|
|
using System.ServiceModel.Dispatcher;
|
|
|
|
using System.Text;
|
|
using NUnit.Framework;
|
|
|
|
//------------------------------------------------------------------------------
|
|
// <auto-generated>
|
|
// This code was generated by a tool.
|
|
// Runtime Version:4.0.30319.239
|
|
//
|
|
// Changes to this file may cause incorrect behavior and will be lost if
|
|
// the code is regenerated.
|
|
// </auto-generated>
|
|
//------------------------------------------------------------------------------
|
|
|
|
namespace Client2843.EvalServiceReference {
|
|
using System.Runtime.Serialization;
|
|
using System;
|
|
|
|
|
|
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
|
|
[System.Runtime.Serialization.DataContractAttribute(Name="Eval", Namespace="http://schemas.datacontract.org/2004/07/WcfServiceLibrary1")]
|
|
[System.SerializableAttribute()]
|
|
public partial class Eval : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
|
|
|
|
[System.NonSerializedAttribute()]
|
|
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
|
|
|
|
[System.Runtime.Serialization.OptionalFieldAttribute()]
|
|
private string CommentsField;
|
|
|
|
[System.Runtime.Serialization.OptionalFieldAttribute()]
|
|
private string IdField;
|
|
|
|
[System.Runtime.Serialization.OptionalFieldAttribute()]
|
|
private string SubmitterField;
|
|
|
|
[System.Runtime.Serialization.OptionalFieldAttribute()]
|
|
private System.Nullable<System.DateTime> TimeSubmittedField;
|
|
|
|
[System.Runtime.Serialization.OptionalFieldAttribute()]
|
|
private System.Nullable<Client2843.EvalServiceReference.EvalType> etypeField;
|
|
|
|
[System.Runtime.Serialization.OptionalFieldAttribute()]
|
|
private System.Nullable<Client2843.EvalServiceReference.EvalType> etype2Field;
|
|
|
|
[global::System.ComponentModel.BrowsableAttribute(false)]
|
|
public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
|
|
get {
|
|
return this.extensionDataField;
|
|
}
|
|
set {
|
|
this.extensionDataField = value;
|
|
}
|
|
}
|
|
|
|
[System.Runtime.Serialization.DataMemberAttribute()]
|
|
public string Comments {
|
|
get {
|
|
return this.CommentsField;
|
|
}
|
|
set {
|
|
if ((object.ReferenceEquals(this.CommentsField, value) != true)) {
|
|
this.CommentsField = value;
|
|
this.RaisePropertyChanged("Comments");
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.Runtime.Serialization.DataMemberAttribute()]
|
|
public string Id {
|
|
get {
|
|
return this.IdField;
|
|
}
|
|
set {
|
|
if ((object.ReferenceEquals(this.IdField, value) != true)) {
|
|
this.IdField = value;
|
|
this.RaisePropertyChanged("Id");
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.Runtime.Serialization.DataMemberAttribute()]
|
|
public string Submitter {
|
|
get {
|
|
return this.SubmitterField;
|
|
}
|
|
set {
|
|
if ((object.ReferenceEquals(this.SubmitterField, value) != true)) {
|
|
this.SubmitterField = value;
|
|
this.RaisePropertyChanged("Submitter");
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.Runtime.Serialization.DataMemberAttribute()]
|
|
public System.Nullable<System.DateTime> TimeSubmitted {
|
|
get {
|
|
return this.TimeSubmittedField;
|
|
}
|
|
set {
|
|
if ((this.TimeSubmittedField.Equals(value) != true)) {
|
|
this.TimeSubmittedField = value;
|
|
this.RaisePropertyChanged("TimeSubmitted");
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.Runtime.Serialization.DataMemberAttribute()]
|
|
public System.Nullable<Client2843.EvalServiceReference.EvalType> etype {
|
|
get {
|
|
return this.etypeField;
|
|
}
|
|
set {
|
|
if ((this.etypeField.Equals(value) != true)) {
|
|
this.etypeField = value;
|
|
this.RaisePropertyChanged("etype");
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.Runtime.Serialization.DataMemberAttribute()]
|
|
public System.Nullable<Client2843.EvalServiceReference.EvalType> etype2 {
|
|
get {
|
|
return this.etype2Field;
|
|
}
|
|
set {
|
|
if ((this.etype2Field.Equals(value) != true)) {
|
|
this.etype2Field = value;
|
|
this.RaisePropertyChanged("etype2");
|
|
}
|
|
}
|
|
}
|
|
|
|
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected void RaisePropertyChanged(string propertyName) {
|
|
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
|
|
if ((propertyChanged != null)) {
|
|
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
|
|
[System.Runtime.Serialization.DataContractAttribute(Name="EvalType", Namespace="http://schemas.datacontract.org/2004/07/WcfServiceLibrary1")]
|
|
public enum EvalType : int {
|
|
|
|
[System.Runtime.Serialization.EnumMemberAttribute()]
|
|
SIMPLE = 1,
|
|
|
|
[System.Runtime.Serialization.EnumMemberAttribute()]
|
|
COMPLEX = 2,
|
|
|
|
[System.Runtime.Serialization.EnumMemberAttribute()]
|
|
NONE = 3,
|
|
}
|
|
|
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
|
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="EvalServiceReference.IEvalService")]
|
|
public interface IEvalService {
|
|
|
|
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IEvalService/SubmitEval", ReplyAction="http://tempuri.org/IEvalService/SubmitEvalResponse")]
|
|
void SubmitEval(Client2843.EvalServiceReference.Eval eval);
|
|
|
|
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IEvalService/GetEvals", ReplyAction="http://tempuri.org/IEvalService/GetEvalsResponse")]
|
|
Client2843.EvalServiceReference.Eval[] GetEvals();
|
|
|
|
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IEvalService/RemoveEval", ReplyAction="http://tempuri.org/IEvalService/RemoveEvalResponse")]
|
|
void RemoveEval(string id);
|
|
}
|
|
|
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
|
public interface IEvalServiceChannel : Client2843.EvalServiceReference.IEvalService, System.ServiceModel.IClientChannel {
|
|
}
|
|
|
|
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
|
public partial class EvalServiceClient : System.ServiceModel.ClientBase<Client2843.EvalServiceReference.IEvalService>, Client2843.EvalServiceReference.IEvalService {
|
|
|
|
public EvalServiceClient() {
|
|
}
|
|
|
|
public EvalServiceClient(string endpointConfigurationName) :
|
|
base(endpointConfigurationName) {
|
|
}
|
|
|
|
public EvalServiceClient(string endpointConfigurationName, string remoteAddress) :
|
|
base(endpointConfigurationName, remoteAddress) {
|
|
}
|
|
|
|
public EvalServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
|
|
base(endpointConfigurationName, remoteAddress) {
|
|
}
|
|
|
|
public EvalServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
|
|
base(binding, remoteAddress) {
|
|
}
|
|
|
|
public void SubmitEval(Client2843.EvalServiceReference.Eval eval) {
|
|
base.Channel.SubmitEval(eval);
|
|
}
|
|
|
|
public Client2843.EvalServiceReference.Eval[] GetEvals() {
|
|
return base.Channel.GetEvals();
|
|
}
|
|
|
|
public void RemoveEval(string id) {
|
|
base.Channel.RemoveEval(id);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
namespace MonoTests.System.Runtime.Serialization
|
|
{
|
|
[TestFixture]
|
|
public class Bug2843Test
|
|
{
|
|
[Test]
|
|
public void TestNullableEnum()
|
|
{
|
|
string Name = "GetEvalsResult";
|
|
string Wrapper = "GetEvalsResponse";
|
|
string Namespace = "http://tempuri.org/";
|
|
|
|
Type type = typeof(Client2843.EvalServiceReference.Eval[]);
|
|
IEnumerable<Type> know_types = new List<Type>();
|
|
|
|
// This is the XML generated by WCF Server
|
|
string xml = "<GetEvalsResponse xmlns=\"http://tempuri.org/\"> <GetEvalsResult xmlns:a=\"http://schemas.datacontract.org/2004/07/WcfServiceLibrary1\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"> <a:Eval> <a:Comments>Comment 1</a:Comments> <a:Id>04836718-41a7-45fe-8c0b-ac3fc613b0f8</a:Id> <a:Submitter>Submitter 1</a:Submitter> <a:TimeSubmitted i:nil=\"true\" /> <a:etype>SIMPLE</a:etype> <a:etype2>COMPLEX</a:etype2> </a:Eval> <a:Eval> <a:Comments>Comment 2</a:Comments> <a:Id>fd17a406-4c2c-41ca-9a5d-1a1019d07535</a:Id> <a:Submitter>Submitter 2</a:Submitter> <a:TimeSubmitted>2012-02-26T13:41:00</a:TimeSubmitted> <a:etype i:nil=\"true\" /> <a:etype2>COMPLEX</a:etype2> </a:Eval> </GetEvalsResult> </GetEvalsResponse>";
|
|
|
|
Client2843.EvalServiceReference.Eval[] evals = null;
|
|
|
|
StringBuilder stringBuilder = new StringBuilder ();
|
|
|
|
var ds = new DataContractSerializer (type, Name, Namespace, know_types);
|
|
|
|
using (var xr = XmlDictionaryReader.CreateDictionaryReader ( XmlReader.Create (new StringReader (xml))))
|
|
{
|
|
xr.ReadStartElement (Wrapper, Namespace);
|
|
|
|
for (xr.MoveToContent (); xr.NodeType == XmlNodeType.Element; xr.MoveToContent ()) {
|
|
XmlQualifiedName key = new XmlQualifiedName (xr.LocalName, xr.NamespaceURI);
|
|
|
|
if ( Name == key.Name && Namespace == key.Namespace)
|
|
break;
|
|
}
|
|
|
|
evals = (Client2843.EvalServiceReference.Eval[])ds.ReadObject (xr, true);
|
|
}
|
|
|
|
using (var xw = XmlDictionaryWriter.CreateDictionaryWriter ( XmlWriter.Create( new StringWriter(stringBuilder)))) {
|
|
ds.WriteObject (xw, evals);
|
|
}
|
|
|
|
string actualXml = stringBuilder.ToString ();
|
|
|
|
Assert.AreEqual (evals.Length, 2, "Comment 1" , "Eval 1 Comment missmatch");
|
|
|
|
Client2843.EvalServiceReference.Eval ev1 = evals[0];
|
|
Client2843.EvalServiceReference.Eval ev2 = evals[1];
|
|
|
|
// Assert that object deserilized matches each value attribute.
|
|
Assert.AreEqual (ev1.Comments, "Comment 1" , "ev1.Comments missmatch");
|
|
Assert.AreEqual (ev1.Submitter, "Submitter 1", "ev1.Submitter missmatch");
|
|
Assert.IsNull (ev1.TimeSubmitted, "ev1.TimeSubmitted missmatch");
|
|
Assert.AreEqual (ev1.etype, Client2843.EvalServiceReference.EvalType.SIMPLE, "ev1.etype missmatch");
|
|
Assert.AreEqual (ev1.etype2, Client2843.EvalServiceReference.EvalType.COMPLEX, "ev1.etype2 missmatch");
|
|
|
|
Assert.AreEqual (ev2.Comments, "Comment 2", "ev2.Comments missmatch");
|
|
Assert.AreEqual (ev2.Submitter, "Submitter 2","ev2.Submitter missmatch");
|
|
Assert.AreEqual (ev2.TimeSubmitted, DateTime.Parse("2012-02-26T13:41:00"), "ev2.TimeSubmitted missmatch");
|
|
Assert.IsNull (ev2.etype, "ev2.etype missmatch");
|
|
Assert.AreEqual (ev2.etype2, Client2843.EvalServiceReference.EvalType.COMPLEX, "ev2.etype2 missmatch");
|
|
|
|
|
|
Client2843.EvalServiceReference.Eval[] evals2 = null;
|
|
|
|
using (var xr = XmlDictionaryReader.CreateDictionaryReader ( XmlReader.Create (new StringReader (actualXml))))
|
|
{
|
|
evals2 = (Client2843.EvalServiceReference.Eval[])ds.ReadObject (xr, true);
|
|
}
|
|
|
|
Client2843.EvalServiceReference.Eval e1 = evals2[0];
|
|
Client2843.EvalServiceReference.Eval e2 = evals2[1];
|
|
|
|
Assert.AreEqual (e1.Comments, "Comment 1" , "e1.Comments missmatch");
|
|
Assert.AreEqual (e1.Submitter, "Submitter 1", "e1.Submitter missmatch");
|
|
Assert.IsNull (e1.TimeSubmitted, "e1.TimeSubmitted missmatch");
|
|
Assert.AreEqual (e1.etype, Client2843.EvalServiceReference.EvalType.SIMPLE, "e1.etype missmatch");
|
|
Assert.AreEqual (e1.etype2, Client2843.EvalServiceReference.EvalType.COMPLEX, "e1.etype2 missmatch");
|
|
|
|
Assert.AreEqual (e2.Comments, "Comment 2", "e2.Comments missmatch");
|
|
Assert.AreEqual (e2.Submitter, "Submitter 2","e2.Submitter missmatch");
|
|
Assert.AreEqual (e2.TimeSubmitted, DateTime.Parse("2012-02-26T13:41:00"), "e2.TimeSubmitted missmatch");
|
|
Assert.IsNull (e2.etype, "e2.etype missmatch");
|
|
Assert.AreEqual (e2.etype2, Client2843.EvalServiceReference.EvalType.COMPLEX, "e2.etype2 missmatch");
|
|
}
|
|
}
|
|
}
|