public void AdminAccountSearchConstructorTest() { ClientVersion version = ClientVersion.vMAX; AdminAccountSearch.AcctSearchType type = AdminAccountSearch.AcctSearchType.Username; string term = "a username"; AdminAccountSearch target = new AdminAccountSearch(version, type, term); PacketWriter writer = target.GetWriter(); ClientPacketId packetidActual = (ClientPacketId)writer.Packet[0]; ushort packetlen = (ushort)((writer.Packet[1] << 8) | writer.Packet[2]); RemoteAdminSubCommand commandidActual = (RemoteAdminSubCommand)writer.Packet[3]; AdminAccountSearch.AcctSearchType typeActual = (AdminAccountSearch.AcctSearchType)writer.Packet[4]; string termActual = System.Text.Encoding.ASCII.GetString(writer.Packet, 5, packetlen - 6); ClientPacketId packetidExpected = ClientPacketId.RemoteAdmin; RemoteAdminSubCommand commandidExpected = RemoteAdminSubCommand.AccountSearch; AdminAccountSearch.AcctSearchType typeExpected = type; string termExpected = term; Assert.AreEqual(packetidExpected, packetidActual); Assert.AreEqual(commandidExpected, commandidActual); Assert.AreEqual(termExpected, termActual); }
public void AdminUpdateAccountConstructorTest() { ClientVersion version = ClientVersion.vMAX; AdminUpdateAccount.UpdateAccountArg arg; arg.Username = "******"; arg.Password = "******"; arg.AccessLevel = AccessLevel.Developer; arg.Banned = true; arg.AddressRestrictions = new List <string>() { "aAaa", "bBb", "ccC" }; ushort expectedRestrictionCount = (ushort)arg.AddressRestrictions.Count(); AdminUpdateAccount target = new AdminUpdateAccount(version, arg); Assert.IsNotNull(target); PacketWriter writer = target.GetWriter(); Assert.IsNotNull(writer.Packet); int index = 3; RemoteAdminSubCommand actualPacketID = (RemoteAdminSubCommand)writer.Packet[index++]; string actualUsername = string.Empty; while (index < writer.Packet.Length && writer.Packet[index] != 0) { actualUsername += (char)writer.Packet[index++]; } index++; string actualPassword = string.Empty; while (index < writer.Packet.Length && writer.Packet[index] != 0) { actualPassword += (char)writer.Packet[index++]; } index++; AccessLevel actualAccessLevel = (AccessLevel)writer.Packet[index++]; bool actualBanned = writer.Packet[index++] != 0 ? true : false; ushort actualRestCount = (ushort)((writer.Packet[index++] << 8) | writer.Packet[index++]); List <string> actualAddressRestrictions = new List <string>(); for (int i = 0; i < actualRestCount; i++) { string restriction = string.Empty; while (index < writer.Packet.Length && writer.Packet[index] != 0) { restriction += (char)writer.Packet[index++]; } index++; actualAddressRestrictions.Add(restriction); } Assert.AreEqual(RemoteAdminSubCommand.UpdateAccount, actualPacketID); Assert.AreEqual(arg.Username, actualUsername); Assert.AreEqual(arg.Password, actualPassword); Assert.AreEqual(arg.AccessLevel, actualAccessLevel); Assert.AreEqual(arg.Banned, actualBanned); Assert.AreEqual(expectedRestrictionCount, actualRestCount); for (ushort i = 0; i < actualRestCount; i++) { Assert.AreEqual(arg.AddressRestrictions.ElementAt(i), actualAddressRestrictions.ElementAt(i)); } }