Skip to content

Commit

Permalink
fix equal tests (#944)
Browse files Browse the repository at this point in the history
* fix equal tests

* fix test
  • Loading branch information
DominikHerold authored and NickCraver committed Feb 14, 2018
1 parent 17ffdc2 commit 80231b4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions Dapper.Tests/AsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ public async Task TestClassWithStringUsageAsync()
public async Task TestExecuteAsync()
{
var val = await connection.ExecuteAsync("declare @foo table(id int not null); insert @foo values(@id);", new { id = 1 }).ConfigureAwait(false);
val.Equals(1);
Assert.Equal(1, val);
}

[Fact]
public void TestExecuteClosedConnAsyncInner()
{
var query = connection.ExecuteAsync("declare @foo table(id int not null); insert @foo values(@id);", new { id = 1 });
var val = query.Result;
val.Equals(1);
Assert.Equal(1, val);
}

[Fact]
Expand Down
20 changes: 10 additions & 10 deletions Dapper.Tests/DecimalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,31 @@ public void TestDoubleDecimalConversions_SO18228523_RightWay()
{
var row = connection.Query<HasDoubleDecimal>(
"select cast(1 as float) as A, cast(2 as float) as B, cast(3 as decimal) as C, cast(4 as decimal) as D").Single();
row.A.Equals(1.0);
row.B.Equals(2.0);
row.C.Equals(3.0M);
row.D.Equals(4.0M);
Assert.Equal(1.0, row.A);
Assert.Equal(2.0, row.B);
Assert.Equal(3.0M, row.C);
Assert.Equal(4.0M, row.D);
}

[Fact]
public void TestDoubleDecimalConversions_SO18228523_WrongWay()
{
var row = connection.Query<HasDoubleDecimal>(
"select cast(1 as decimal) as A, cast(2 as decimal) as B, cast(3 as float) as C, cast(4 as float) as D").Single();
row.A.Equals(1.0);
row.B.Equals(2.0);
row.C.Equals(3.0M);
row.D.Equals(4.0M);
Assert.Equal(1.0, row.A);
Assert.Equal(2.0, row.B);
Assert.Equal(3.0M, row.C);
Assert.Equal(4.0M, row.D);
}

[Fact]
public void TestDoubleDecimalConversions_SO18228523_Nulls()
{
var row = connection.Query<HasDoubleDecimal>(
"select cast(null as decimal) as A, cast(null as decimal) as B, cast(null as float) as C, cast(null as float) as D").Single();
row.A.Equals(0.0);
Assert.Equal(0.0, row.A);
Assert.Null(row.B);
row.C.Equals(0.0M);
Assert.Equal(0.0M, row.C);
Assert.Null(row.D);
}

Expand Down
12 changes: 6 additions & 6 deletions Dapper.Tests/LiteralTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public void LiteralReplacementEnumAndString()
AnEnum x = (AnEnum)(int)row.x;
decimal y = row.y;
AnotherEnum z = (AnotherEnum)(byte)row.z;
x.Equals(AnEnum.B);
y.Equals(123.45M);
z.Equals(AnotherEnum.A);
Assert.Equal(AnEnum.B, x);
Assert.Equal(123.45M, y);
Assert.Equal(AnotherEnum.A, z);
}

[Fact]
Expand All @@ -29,9 +29,9 @@ public void LiteralReplacementDynamicEnumAndString()
AnEnum x = (AnEnum)(int)row.x;
decimal y = row.y;
AnotherEnum z = (AnotherEnum)(byte)row.z;
x.Equals(AnEnum.B);
y.Equals(123.45M);
z.Equals(AnotherEnum.A);
Assert.Equal(AnEnum.B, x);
Assert.Equal(123.45M, y);
Assert.Equal(AnotherEnum.A, z);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Dapper.Tests/MiscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public void TestNullableCharInputAndOutputNull()
public void WorkDespiteHavingWrongStructColumnTypes()
{
var hazInt = connection.Query<CanHazInt>("select cast(1 as bigint) Value").Single();
hazInt.Value.Equals(1);
Assert.Equal(1, hazInt.Value);
}

private struct CanHazInt
Expand Down
12 changes: 6 additions & 6 deletions Dapper.Tests/MultiMapTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -599,15 +599,15 @@ public void TestSplitWithMissingMembers()
(T, P) => { T.Author = P; return T; },
null, null, true, "ID,Name").Single();

result.ID.Equals(123);
result.Title.Equals("abc");
result.CreateDate.Equals(new DateTime(2013, 2, 1));
Assert.Equal(123, result.ID);
Assert.Equal("abc", result.Title);
Assert.Equal(new DateTime(2013, 2, 1), result.CreateDate);
Assert.Null(result.Name);
Assert.Null(result.Content);

result.Author.Phone.Equals("def");
result.Author.Name.Equals("ghi");
result.Author.ID.Equals(0);
Assert.Equal("def", result.Author.Phone);
Assert.Equal("ghi", result.Author.Name);
Assert.Equal(0, result.Author.ID);
Assert.Null(result.Author.Address);
}

Expand Down
34 changes: 17 additions & 17 deletions Dapper.Tests/ParameterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,20 @@ public void GuidIn_SO_24177902()

// check that rows 2&3 yield guids b&c
var guids = connection.Query<Guid>("select g from #foo where i in (2,3)").ToArray();
guids.Length.Equals(2);
guids.Contains(a).Equals(false);
guids.Contains(b).Equals(true);
guids.Contains(c).Equals(true);
guids.Contains(d).Equals(false);
Assert.Equal(2, guids.Length);
Assert.DoesNotContain(a, guids);
Assert.Contains(b, guids);
Assert.Contains(c, guids);
Assert.DoesNotContain(d, guids);

// in query on the guids
var rows = connection.Query("select * from #foo where g in @guids order by i", new { guids })
.Select(row => new { i = (int)row.i, g = (Guid)row.g }).ToArray();
rows.Length.Equals(2);
rows[0].i.Equals(2);
rows[0].g.Equals(b);
rows[1].i.Equals(3);
rows[1].g.Equals(c);
Assert.Equal(2, rows.Length);
Assert.Equal(2, rows[0].i);
Assert.Equal(b, rows[0].g);
Assert.Equal(3, rows[1].i);
Assert.Equal(c, rows[1].g);
}

[FactUnlessCaseSensitiveDatabase]
Expand Down Expand Up @@ -514,8 +514,8 @@ public void DataTableParametersWithExtendedProperty()
public void SupportInit()
{
var obj = connection.Query<WithInit>("select 'abc' as Value").Single();
obj.Value.Equals("abc");
obj.Flags.Equals(31);
Assert.Equal("abc", obj.Value);
Assert.Equal(31, obj.Flags);
}

public class WithInit : ISupportInitialize
Expand Down Expand Up @@ -656,7 +656,7 @@ public void SqlHierarchyId_SO18888911()
{
SqlMapper.ResetTypeHandlers();
var row = connection.Query<HazSqlHierarchy>("select 3 as [Id], hierarchyid::Parse('/1/2/3/') as [Path]").Single();
row.Id.Equals(3);
Assert.Equal(3, row.Id);
Assert.NotEqual(default(SqlHierarchyId), row.Path);

var val = connection.Query<SqlHierarchyId>("select @Path", row).Single();
Expand Down Expand Up @@ -1189,8 +1189,8 @@ public void Issue151_ExpandoObjectArgsQuery()
args.Name = "abc";

var row = connection.Query("select @Id as [Id], @Name as [Name]", (object)args).Single();
((int)row.Id).Equals(123);
((string)row.Name).Equals("abc");
Assert.Equal(123, (int)row.Id);
Assert.Equal("abc", (string)row.Name);
}

[Fact]
Expand All @@ -1202,8 +1202,8 @@ public void Issue151_ExpandoObjectArgsExec()
connection.Execute("create table #issue151 (Id int not null, Name nvarchar(20) not null)");
Assert.Equal(1, connection.Execute("insert #issue151 values(@Id, @Name)", (object)args));
var row = connection.Query("select Id, Name from #issue151").Single();
((int)row.Id).Equals(123);
((string)row.Name).Equals("abc");
Assert.Equal(123, (int)row.Id);
Assert.Equal("abc", (string)row.Name);
}

[Fact]
Expand Down
16 changes: 8 additions & 8 deletions Dapper.Tests/QueryMultipleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public void TestQueryMultipleBuffered()
var c = grid.Read<int>();
var d = grid.Read<int>();

a.Single().Equals(1);
b.Single().Equals(2);
c.Single().Equals(3);
d.Single().Equals(4);
Assert.Equal(1, a.Single());
Assert.Equal(2, b.Single());
Assert.Equal(3, c.Single());
Assert.Equal(4, d.Single());
}
}

Expand Down Expand Up @@ -53,10 +53,10 @@ public void TestQueryMultipleNonBufferedCorrectOrder()
var c = grid.Read<int>(false).Single();
var d = grid.Read<int>(false).Single();

a.Equals(1);
b.Equals(2);
c.Equals(3);
d.Equals(4);
Assert.Equal(1, a);
Assert.Equal(2, b);
Assert.Equal(3, c);
Assert.Equal(4, d);
}
}

Expand Down
16 changes: 8 additions & 8 deletions Dapper.Tests/TypeHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,20 +576,20 @@ public class WrongTypes
public void TestWrongTypes_WithRightTypes()
{
var item = connection.Query<WrongTypes>("select 1 as A, cast(2.0 as float) as B, cast(3 as bigint) as C, cast(1 as bit) as D").Single();
item.A.Equals(1);
item.B.Equals(2.0);
item.C.Equals(3L);
item.D.Equals(true);
Assert.Equal(1, item.A);
Assert.Equal(2.0, item.B);
Assert.Equal(3L, item.C);
Assert.True(item.D);
}

[Fact]
public void TestWrongTypes_WithWrongTypes()
{
var item = connection.Query<WrongTypes>("select cast(1.0 as float) as A, 2 as B, 3 as C, cast(1 as bigint) as D").Single();
item.A.Equals(1);
item.B.Equals(2.0);
item.C.Equals(3L);
item.D.Equals(true);
Assert.Equal(1, item.A);
Assert.Equal(2.0, item.B);
Assert.Equal(3L, item.C);
Assert.True(item.D);
}

[Fact]
Expand Down

0 comments on commit 80231b4

Please sign in to comment.