Skip to content

Commit

Permalink
redis cache unity test error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Musa Demir committed Jul 1, 2019
1 parent 76bc61f commit fc212bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Expand Up @@ -30,7 +30,7 @@ public void Serialize_List_Test()
};

var result = _redisCacheSerializer.Serialize(source, typeof(List<string>));
result.ShouldBe("{\"Payload\":\"[\\\"Stranger Things\\\",\\\"The OA\\\",\\\"Lost in Space\\\"]\",\"Type\":\"System.Collections.Generic.List`1[[System.String]]\"}");
result.ShouldBe("{\"Payload\":\"[\\\"Stranger Things\\\",\\\"The OA\\\",\\\"Lost in Space\\\"]\",\"Type\":\"System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"}");
}

[Fact]
Expand All @@ -43,7 +43,7 @@ public void Serialize_Class_Test()
};

var result = _redisCacheSerializer.Serialize(source, typeof(MyTestClass));
result.ShouldBe("{\"Payload\":\"{\\\"Field1\\\":42,\\\"Field2\\\":\\\"Stranger Things\\\"}\",\"Type\":\"Abp.RedisCache.Tests.DefaultRedisCacheSerializer_Tests+MyTestClass, Abp.RedisCache.Tests\"}");
result.ShouldBe("{\"Payload\":\"{\\\"Field1\\\":42,\\\"Field2\\\":\\\"Stranger Things\\\"}\",\"Type\":\"Abp.RedisCache.Tests.DefaultRedisCacheSerializer_Tests+MyTestClass, Abp.RedisCache.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\"}");
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions test/Abp.Tests/Runtime/Caching/AbpCacheData_Tests.cs
Expand Up @@ -21,7 +21,7 @@ public void Serialize_List_Test()
};

var result = AbpCacheData.Serialize(source);
result.Type.ShouldBe("System.Collections.Generic.List`1[[System.String]]");
result.Type.ShouldBe("System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
result.Payload.ShouldBe("[\"Stranger Things\",\"The OA\",\"Lost in Space\"]");
}

Expand All @@ -35,7 +35,7 @@ public void Serialize_Class_Test()
};

var result = AbpCacheData.Serialize(source);
result.Type.ShouldBe("Abp.Tests.Runtime.Caching.AbpCacheData_Tests+MyTestClass, Abp.Tests");
result.Type.ShouldBe("Abp.Tests.Runtime.Caching.AbpCacheData_Tests+MyTestClass, Abp.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
result.Payload.ShouldBe("{\"Field1\":42,\"Field2\":\"Stranger Things\"}");
}

Expand Down

2 comments on commit fc212bd

@maliming
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @demirmusa
Unit test failed on my machine.

Shouldly.ShouldAssertException : result
    should be
"{"Payload":"[\"Stranger Things\",\"The OA\",\"Lost in Space\"]","Type":"System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"}"
    but was
"{"Payload":"[\"Stranger Things\",\"The OA\",\"Lost in Space\"]","Type":"System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"}"


Shouldly.ShouldAssertException : result.Type
    should be
"System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    but was
"System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"

image

@demirmusa
Copy link
Contributor

@demirmusa demirmusa commented on fc212bd Jul 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @maliming. Yes there is something interesting here. if i use visualstudio test window to test it, test uses mscorlib.dll and with this way it passes the test(like i did before). But if i use dotnet test command or resharper unit test window(like you did), it uses System.Private.CoreLib.dll and test fails.
I am on it.

Please sign in to comment.