Skip to content

Commit

Permalink
优化单元测试,创建WxOpenBaseTest基类
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySu committed Jul 28, 2018
1 parent 1dd0454 commit ab2485b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Senparc.Weixin.MP/Senparc.WeixinTests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void RegisterServiceCollection()
var configBuilder = new ConfigurationBuilder();
var config = configBuilder.Build();
serviceCollection.AddSenparcGlobalServices(config);
//serviceCollection.AddMemoryCache();//使用内存缓存
serviceCollection.AddMemoryCache();//使用内存缓存
}
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="Moq" Version="4.8.3" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public WxOpenTemplateMessage_PaySuccessNotice(


[TestClass()]
public class TemplateApiTests:CommonApiTest
public class TemplateApiTests: WxOpenBaseTest
{
[TestMethod()]
public void SendTemplateMessageTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ and limitations under the License.
namespace Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.Tests
{
[TestClass()]
public class WxAppApiTests : CommonApiTest
public class WxAppApiTests : WxOpenBaseTest
{
[TestMethod()]
public void CreateWxaQrCodeTest()
Expand Down Expand Up @@ -107,7 +107,11 @@ public void CreateWxaQrCodeAsyncTest()
public void CreateWxaQrCodeAsyncTest2()
{
var dt1 = DateTime.Now;
#if NETCOREAPP2_0 || NETCOREAPP2_1
var filePath = "../../../Config/qr-async2.jpg";
#else
var filePath = "../../Config/qr-async2.jpg";
#endif
Task.Factory.StartNew(async () =>
{
var result = await WxAppApi.CreateWxQrCodeAsync(base._wxOpenAppId, filePath, "pages/websocket", 100);
Expand All @@ -128,7 +132,11 @@ public void CreateWxaQrCodeAsyncTest2()
[TestMethod]
public void GetWxaCodeUnlimitTest()
{
var filePath = "../../Config/qr-unlimit.jpg";
#if NETCOREAPP2_0 || NETCOREAPP2_1
var filePath = "../../../Config/qr-async2.jpg";
#else
var filePath = "../../Config/qr-async2.jpg";
# endif
var scene = "";
var result = WxAppApi.GetWxaCodeUnlimit(base._wxOpenAppId,filePath, scene, "pages/websocket", 100);
Assert.IsNotNull(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and limitations under the License.
namespace Senparc.Weixin.WxOpen.Containers.Tests
{
[TestClass()]
public class SessionContainerTests:CommonApiTest
public class SessionContainerTests: WxOpenBaseTest
{
[TestMethod()]
public void UpdateSessionTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ and limitations under the License.
namespace Senparc.WeixinTests.Cache
{
[TestClass]
public class SerializeTest : CommonApiTest
public class SerializeTest : WxOpenBaseTest
{
/// <summary>
/// 不同的序列化方式比较
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Senparc.Weixin.MP.Containers;
using Senparc.Weixin.MP.Test.CommonAPIs;
using System;
using System.Collections.Generic;
using System.Text;

namespace Senparc.Weixin.WxOpen.Tests.vs2017
{
public class WxOpenBaseTest : CommonApiTest
{
public WxOpenBaseTest()
{
AccessTokenContainer.Register(base._wxOpenAppId, base._wxOpenAppSecret, "小程序单元测试");
}
}
}

0 comments on commit ab2485b

Please sign in to comment.