forked from loafle/openapi-generator-original
add test case for pet equal
This commit is contained in:
parent
1ce3b67aa4
commit
a8119049ad
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -72,12 +73,17 @@ namespace {{packageName}}.Model
|
|||||||
if (other == null)
|
if (other == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return {{#vars}}
|
return {{#vars}}{{#isNotContainer}}
|
||||||
(
|
(
|
||||||
this.{{name}} == other.{{name}} ||
|
this.{{name}} == other.{{name}} ||
|
||||||
this.{{name}} != null &&
|
this.{{name}} != null &&
|
||||||
this.{{name}}.Equals(other.{{name}})
|
this.{{name}}.Equals(other.{{name}})
|
||||||
){{#hasMore}} && {{/hasMore}}{{/vars}};
|
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
|
||||||
|
(
|
||||||
|
this.{{name}} == other.{{name}} ||
|
||||||
|
this.{{name}} != null &&
|
||||||
|
this.{{name}}.SequenceEqual(other.{{name}})
|
||||||
|
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -126,15 +127,15 @@ namespace IO.Swagger.Model
|
|||||||
this.Name != null &&
|
this.Name != null &&
|
||||||
this.Name.Equals(other.Name)
|
this.Name.Equals(other.Name)
|
||||||
) &&
|
) &&
|
||||||
// (
|
(
|
||||||
// this.PhotoUrls == other.PhotoUrls ||
|
this.PhotoUrls == other.PhotoUrls ||
|
||||||
// this.PhotoUrls != null &&
|
this.PhotoUrls != null &&
|
||||||
// this.PhotoUrls.Equals(other.PhotoUrls)
|
this.PhotoUrls.SequenceEqual(other.PhotoUrls)
|
||||||
// ) &&
|
) &&
|
||||||
(
|
(
|
||||||
this.Tags == other.Tags ||
|
this.Tags == other.Tags ||
|
||||||
this.Tags != null &&
|
this.Tags != null &&
|
||||||
this.Tags.Equals(other.Tags)
|
this.Tags.SequenceEqual(other.Tags)
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
this.Status == other.Status ||
|
this.Status == other.Status ||
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
@ -2,8 +2,25 @@
|
|||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="TestPet.cs" Line="11" Column="2" />
|
<File FileName="TestPet.cs" Line="8" Column="25" />
|
||||||
</Files>
|
</Files>
|
||||||
|
<Pads>
|
||||||
|
<Pad Id="MonoDevelop.NUnit.TestPad">
|
||||||
|
<State name="__root__">
|
||||||
|
<Node name="SwaggerClientTest" expanded="True">
|
||||||
|
<Node name="SwaggerClientTest" expanded="True">
|
||||||
|
<Node name="SwaggerClient" expanded="True">
|
||||||
|
<Node name="TestPet" expanded="True">
|
||||||
|
<Node name="TestPet" expanded="True">
|
||||||
|
<Node name="TestEqual" selected="True" />
|
||||||
|
</Node>
|
||||||
|
</Node>
|
||||||
|
</Node>
|
||||||
|
</Node>
|
||||||
|
</Node>
|
||||||
|
</State>
|
||||||
|
</Pad>
|
||||||
|
</Pads>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
<BreakpointStore />
|
<BreakpointStore />
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using IO.Swagger.Api;
|
using IO.Swagger.Api;
|
||||||
@ -166,7 +167,7 @@ namespace SwaggerClient.TestPet
|
|||||||
p1.Category = category1;
|
p1.Category = category1;
|
||||||
p1.PhotoUrls = photoUrls1;
|
p1.PhotoUrls = photoUrls1;
|
||||||
|
|
||||||
// create pet
|
// create pet 2
|
||||||
Pet p2 = new Pet();
|
Pet p2 = new Pet();
|
||||||
p2.Id = petId;
|
p2.Id = petId;
|
||||||
p2.Name = "Csharp test";
|
p2.Name = "Csharp test";
|
||||||
@ -185,9 +186,25 @@ namespace SwaggerClient.TestPet
|
|||||||
p2.Category = category2;
|
p2.Category = category2;
|
||||||
p2.PhotoUrls = photoUrls2;
|
p2.PhotoUrls = photoUrls2;
|
||||||
|
|
||||||
|
// p1 and p2 should be equal (both object and attribute level)
|
||||||
Assert.IsTrue (category1.Equals (category2));
|
Assert.IsTrue (category1.Equals (category2));
|
||||||
Assert.IsTrue (tag1.Equals (tag2));
|
Assert.IsTrue (tags1.SequenceEqual (tags2));
|
||||||
Assert.IsTrue (p1.Equals(p2));
|
Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls));
|
||||||
|
|
||||||
|
Assert.IsTrue (p1.Equals (p2));
|
||||||
|
|
||||||
|
// update attribute to that p1 and p2 are not equal
|
||||||
|
category2.Name = "new category name";
|
||||||
|
Assert.IsFalse(category1.Equals (category2));
|
||||||
|
|
||||||
|
tags2 = new List<Tag> ();
|
||||||
|
Assert.IsFalse (tags1.SequenceEqual (tags2));
|
||||||
|
|
||||||
|
// photoUrls has not changed so it should be equal
|
||||||
|
Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls));
|
||||||
|
|
||||||
|
Assert.IsFalse (p1.Equals (p2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user