Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
22 | 4 | 5 | 0.979 | class_member_declaration |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 22 | 94 | src/NHibernate.Test/HQL/HQLFunctions.cs |
2 | 20 | 119 | src/NHibernate.Test/HQL/HQLFunctions.cs |
3 | 20 | 142 | src/NHibernate.Test/HQL/HQLFunctions.cs |
4 | 20 | 165 | src/NHibernate.Test/HQL/HQLFunctions.cs |
| ||||
[Test] public void AggregateAvg() { using (ISession s = OpenSession()) { Animal a1 = new Animal("a1", 20); Animal a2 = new Animal("a2", 10); s.Save(a1); s.Save(a2); s.Flush(); } using (ISession s = OpenSession()) { // In Select object result = s.CreateQuery("select avg(a.BodyWeight) from Animal a").UniqueResult(); Assert.AreEqual( typeof(double), result.GetType()); Assert.AreEqual(15D, result); // In where result = s.CreateQuery("select avg(a.BodyWeight) from Animal a having avg(a.BodyWeight)>0").UniqueResult(); Assert.AreEqual( typeof(double), result.GetType()); Assert.AreEqual(15D, result); } } |
| ||||
[Test] public void AggregateMax() { using (ISession s = OpenSession()) { Animal a1 = new Animal("a1", 20); Animal a2 = new Animal("a2", 10); s.Save(a1); s.Save(a2); s.Flush(); } using (ISession s = OpenSession()) { object result = s.CreateQuery("select max(a.BodyWeight) from Animal a").UniqueResult(); Assert.AreEqual( typeof(float), result.GetType()); //use column type Assert.AreEqual(20F, result); result = s.CreateQuery("select max(a.BodyWeight) from Animal a having max(a.BodyWeight)>0").UniqueResult(); Assert.AreEqual( typeof(float), result.GetType()); //use column type Assert.AreEqual(20F, result); } } |
| ||||
[Test] public void AggregateMin() { using (ISession s = OpenSession()) { Animal a1 = new Animal("a1", 20); Animal a2 = new Animal("a2", 10); s.Save(a1); s.Save(a2); s.Flush(); } using (ISession s = OpenSession()) { object result = s.CreateQuery("select min(a.BodyWeight) from Animal a").UniqueResult(); Assert.AreEqual( typeof(float), result.GetType()); //use column type Assert.AreEqual(10F, result); result = s.CreateQuery("select min(a.BodyWeight) from Animal a having min(a.BodyWeight)>0").UniqueResult(); Assert.AreEqual( typeof(float), result.GetType()); //use column type Assert.AreEqual(10F, result); } } |
| ||||
[Test] public void AggregateSum() { using (ISession s = OpenSession()) { Animal a1 = new Animal("a1", 20); Animal a2 = new Animal("a2", 10); s.Save(a1); s.Save(a2); s.Flush(); } using (ISession s = OpenSession()) { object result = s.CreateQuery("select sum(a.BodyWeight) from Animal a").UniqueResult(); Assert.AreEqual( typeof(double), result.GetType()); Assert.AreEqual(30D, result); result = s.CreateQuery("select sum(a.BodyWeight) from Animal a having sum(a.BodyWeight)>0").UniqueResult(); Assert.AreEqual( typeof(double), result.GetType()); Assert.AreEqual(30D, result); } } |
| |||
[Test] public void [[#variable6e3ffac0]]() { using (ISession s = OpenSession()) { Animal a1 = new Animal("a1", 20); Animal a2 = new Animal("a2", 10); s.Save(a1); s.Save(a2); s.Flush(); } using (ISession s = OpenSession()) { // In Select object result = s.CreateQuery( [[#variable701fc900]]).UniqueResult(); Assert.AreEqual( typeof( [[#variable701fc780]]), result.GetType()); //use column type Assert.AreEqual( [[#variable701fc6a0]], result); // In where result = s.CreateQuery( [[#variable701fc5e0]]).UniqueResult(); Assert.AreEqual( typeof( [[#variable701fc780]]), result.GetType()); //use column type Assert.AreEqual( [[#variable701fc6a0]], result); } } |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#6e3ffac0]] | AggregateAvg |
1 | 2 | [[#6e3ffac0]] | AggregateMax |
1 | 3 | [[#6e3ffac0]] | AggregateMin |
1 | 4 | [[#6e3ffac0]] | AggregateSum |
2 | 1 | [[#701fc900]] | "select avg(a.BodyWeight) from Animal a" |
2 | 2 | [[#701fc900]] | "select max(a.BodyWeight) from Animal a" |
2 | 3 | [[#701fc900]] | "select min(a.BodyWeight) from Animal a" |
2 | 4 | [[#701fc900]] | "select sum(a.BodyWeight) from Animal a" |
3 | 1 | [[#701fc780]] | double |
3 | 2 | [[#701fc780]] | float |
3 | 3 | [[#701fc780]] | float |
3 | 4 | [[#701fc780]] | double |
4 | 1 | [[#701fc6a0]] | 15D |
4 | 2 | [[#701fc6a0]] | 20F |
4 | 3 | [[#701fc6a0]] | 10F |
4 | 4 | [[#701fc6a0]] | 30D |
5 | 1 | [[#701fc5e0]] | "select avg(a.BodyWeight) from Animal a having avg(a.BodyWeight)>0" |
5 | 2 | [[#701fc5e0]] | "select max(a.BodyWeight) from Animal a having max(a.BodyWeight)>0" |
5 | 3 | [[#701fc5e0]] | "select min(a.BodyWeight) from Animal a having min(a.BodyWeight)>0" |
5 | 4 | [[#701fc5e0]] | "select sum(a.BodyWeight) from Animal a having sum(a.BodyWeight)>0" |