浏览代码

1.修复平台登入bug

2.完善平台测试
tags/1.0.0
SmallChi 7 年前
父节点
当前提交
66dab9dfe4
共有 4 个文件被更改,包括 35 次插入11 次删除
  1. +21
    -1
      src/GBNewEnergy.Protocol.Test/NEPackageTest.cs
  2. +6
    -6
      src/GBNewEnergy.Protocol/Extensions/NEExtensions.cs
  3. +4
    -0
      src/GBNewEnergy.Protocol/NEBodiesFactory.cs
  4. +4
    -4
      src/GBNewEnergy.Protocol/UpStream/NEPlatformLoginUpStream.cs

+ 21
- 1
src/GBNewEnergy.Protocol.Test/NEPackageTest.cs 查看文件

@@ -161,6 +161,7 @@ namespace GBNewEnergy.Protocol.Test
[Fact] [Fact]
public void NEPlatformLogin1_1() public void NEPlatformLogin1_1()
{ {
// "23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 29 12 06 0C 09 2F 12 00 01 00 00 00 00 73 6D 61 6C 6C 63 68 69 31 32 33 34 35 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 CD"
NEPlatformLoginProperty nEPlatformLoginProperty = new NEPlatformLoginProperty NEPlatformLoginProperty nEPlatformLoginProperty = new NEPlatformLoginProperty
{ {
EncryptMethod = NEEncryptMethod.None, EncryptMethod = NEEncryptMethod.None,
@@ -168,7 +169,6 @@ namespace GBNewEnergy.Protocol.Test
UserName = "smallchi", UserName = "smallchi",
}; };
NEPlatformLoginUpStream nEPlatformLoginUpStream = new NEPlatformLoginUpStream(nEPlatformLoginProperty, NEGlobalConfigs); NEPlatformLoginUpStream nEPlatformLoginUpStream = new NEPlatformLoginUpStream(nEPlatformLoginProperty, NEGlobalConfigs);

INEProperties nEPackageProperty = new NEPackageProperty INEProperties nEPackageProperty = new NEPackageProperty
{ {
Bodies = nEPlatformLoginUpStream, Bodies = nEPlatformLoginUpStream,
@@ -182,6 +182,16 @@ namespace GBNewEnergy.Protocol.Test
string packageHex = nEPackage.Buffer.ToHexString(); string packageHex = nEPackage.Buffer.ToHexString();
} }


[Fact]
public void NEPlatformLogin1_2()
{
byte[] packageBytes = "23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 29 12 06 0C 09 2F 12 00 01 00 00 00 00 73 6D 61 6C 6C 63 68 69 31 32 33 34 35 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 CD".ToHexBytes();
NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs);
string headerHex = nEPackage.Header.ToHexString();
string bodiesHex = nEPackage.Bodies.Buffer.ToHexString();
string packageHex = nEPackage.Buffer.ToHexString();
}

#endregion #endregion


#region 平台登出(依赖平台登出的流水号所有必须先进行登入产生流水号) #region 平台登出(依赖平台登出的流水号所有必须先进行登入产生流水号)
@@ -189,6 +199,7 @@ namespace GBNewEnergy.Protocol.Test
[Fact] [Fact]
public void NEPlatformLogin2_1() public void NEPlatformLogin2_1()
{ {
//"23 23 06 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 29 12 06 0C 09 3A 17 00 01 00 00 00 00 73 6D 61 6C 6C 63 68 69 31 32 33 34 35 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 DE"
NEPlatformLoginProperty nEPlatformLoginProperty = new NEPlatformLoginProperty NEPlatformLoginProperty nEPlatformLoginProperty = new NEPlatformLoginProperty
{ {
EncryptMethod = NEEncryptMethod.None, EncryptMethod = NEEncryptMethod.None,
@@ -223,6 +234,15 @@ namespace GBNewEnergy.Protocol.Test
string packageHex = loginNEPackage.Buffer.ToHexString(); string packageHex = loginNEPackage.Buffer.ToHexString();
} }


[Fact]
public void NEPlatformLogin2_2()
{
byte[] packageBytes = "23 23 06 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 29 12 06 0C 09 3A 17 00 01 00 00 00 00 73 6D 61 6C 6C 63 68 69 31 32 33 34 35 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 DE".ToHexBytes();
NEPackage loginNEPackage = new NEPackage(packageBytes, NEGlobalConfigs);
string headerHex = loginNEPackage.Header.ToHexString();
string bodiesHex = loginNEPackage.Bodies.Buffer.ToHexString();
string packageHex = loginNEPackage.Buffer.ToHexString();
}


#endregion #endregion
} }


+ 6
- 6
src/GBNewEnergy.Protocol/Extensions/NEExtensions.cs 查看文件

@@ -15,12 +15,12 @@ namespace GBNewEnergy.Protocol.Extensions
public static DateTime ReadDateTimeLittle(this byte[] read,int offset, int len) public static DateTime ReadDateTimeLittle(this byte[] read,int offset, int len)
{ {
return new DateTime( return new DateTime(
read[offset] + DateLimitYear,
read[++offset],
read[++offset],
read[++offset],
read[++offset],
read[++offset]);
read[offset++] + DateLimitYear,
read[offset++],
read[offset++],
read[offset++],
read[offset++],
read[offset++]);
} }


public static ushort ReadUShortH2LLittle(this byte[] read, int offset, int len) public static ushort ReadUShortH2LLittle(this byte[] read, int offset, int len)


+ 4
- 0
src/GBNewEnergy.Protocol/NEBodiesFactory.cs 查看文件

@@ -22,6 +22,10 @@ namespace GBNewEnergy.Protocol
return new NELoginUpStream(buf, nEConfigs); return new NELoginUpStream(buf, nEConfigs);
case NEMsgId.loginout: case NEMsgId.loginout:
return new NELogoutUpStream(buf, nEConfigs); return new NELogoutUpStream(buf, nEConfigs);
case NEMsgId.platformlogin:
return new NEPlatformLoginUpStream(buf, nEConfigs);
case NEMsgId.platformlogout:
return new NEPlatformLogoutUpStream(buf, nEConfigs);
default: default:
return null; return null;
} }


+ 4
- 4
src/GBNewEnergy.Protocol/UpStream/NEPlatformLoginUpStream.cs 查看文件

@@ -70,9 +70,9 @@ namespace GBNewEnergy.Protocol.UpStream
{ {
CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6);
LoginNum = Buffer.ReadUShortH2LLittle(6, 2); LoginNum = Buffer.ReadUShortH2LLittle(6, 2);
UserName = Buffer.ReadStringLittle(6, 12);
Password = Buffer.ReadStringLittle(12, 20);
EncryptMethod= (NEEncryptMethod)Buffer[21];
UserName = Buffer.ReadStringLittle(8, 12);
Password = Buffer.ReadStringLittle(20, 20);
EncryptMethod= (NEEncryptMethod)Buffer[40];
} }


protected override void ToBuffer() protected override void ToBuffer()
@@ -82,7 +82,7 @@ namespace GBNewEnergy.Protocol.UpStream
Buffer.WriteLittle(LoginNum, 6, 2); Buffer.WriteLittle(LoginNum, 6, 2);
Buffer.WriteLittle(UserName, 12); Buffer.WriteLittle(UserName, 12);
Buffer.WriteLittle(Password, 20); Buffer.WriteLittle(Password, 20);
Buffer.WriteLittle((byte)EncryptMethod, 21);
Buffer.WriteLittle((byte)EncryptMethod, 40);
} }
} }
} }

正在加载...
取消
保存