Skip to content

Commit ac13954

Browse files
committed
fix CachedEntity unit-test
1 parent 499a2df commit ac13954

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/SmartSql.Test.Unit/Cache/CachedEntity.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,23 @@ namespace SmartSql.Test.Unit.Cache
55
public class CachedEntity
66
{
77
public string Name { get; set; }
8+
9+
protected bool Equals(CachedEntity other)
10+
{
11+
return Name == other.Name;
12+
}
13+
14+
public override bool Equals(object obj)
15+
{
16+
if (ReferenceEquals(null, obj)) return false;
17+
if (ReferenceEquals(this, obj)) return true;
18+
if (obj.GetType() != this.GetType()) return false;
19+
return Equals((CachedEntity)obj);
20+
}
21+
22+
public override int GetHashCode()
23+
{
24+
return (Name != null ? Name.GetHashCode() : 0);
25+
}
826
}
927
}

src/SmartSql.Test.Unit/Cache/LruCacheProviderTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void GetByCacheFromRequest()
4747
SqlId = "GetByCacheFromRequest",
4848
Request = new { CacheKey = "CacheKey" }
4949
});
50-
Assert.Equal(list.GetHashCode(), cachedList.GetHashCode());
50+
Assert.Equal(list, cachedList);
5151
}
5252
}
5353
}

src/SmartSql.Test.Unit/DyRepository/UsedCacheRepositoryTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public UsedCacheRepositoryTest(SmartSqlFixture smartSqlFixture)
1919
public void GetNow()
2020
{
2121
var datetime = _usedCacheRepository.GetNow();
22-
Thread.Sleep(1000);
22+
Thread.Sleep(2000);
2323
var datetime1 = _usedCacheRepository.GetNow();
2424
Assert.Equal(datetime, datetime1);
2525
}

0 commit comments

Comments
 (0)