public void TestConstructor() { // Create a serial number string serialStr = "01300000000000000000000000000001"; SerialNumber serialNum = new SerialNumber(serialStr); // Test the serial number Assert.AreEqual(serialStr, serialNum.ToString(), string.Format("Serial number strings did not match {0} {1}", serialStr, serialNum.ToString())); Assert.AreEqual(1, serialNum.SubSystemsDict.Count, string.Format("Number of SubSystems did not match 1 {0}", serialNum.SubSystemsDict.Count)); Subsystem ss = new Subsystem("3", 0); Assert.AreEqual(ss, serialNum.SubSystemsDict[0], string.Format("Subsystems do not match {0} {1}", ss.ToString(), serialNum.SubSystemsDict[0].ToString())); Assert.AreEqual(1, serialNum.SystemSerialNumber, string.Format("Serial numbers do not match {0} {1}", 1, serialNum.SystemSerialNumber)); }
public void TestMultipleSubsystems() { // Create a serial number string serialStr = "01KBXV00000000000000000000000001"; SerialNumber serialNum = new SerialNumber(serialStr); // Test the serial number Assert.AreEqual(serialStr, serialNum.ToString(), string.Format("Serial number strings did not match {0} {1}", serialStr, serialNum.ToString())); Assert.AreEqual(4, serialNum.SubSystemsDict.Count, string.Format("Number of SubSystems did not match 4 {0}", serialNum.SubSystemsDict.Count)); // Upper case K Subsystem ss = new Subsystem("K", 0); Assert.AreEqual(ss, serialNum.SubSystemsDict[0], string.Format("Subsystems do not match {0} {1}", ss.ToString(), serialNum.SubSystemsDict[0].ToString())); // Lower case K Subsystem ssNot = new Subsystem("k", 0); Assert.AreNotEqual(ssNot, serialNum.SubSystemsDict[0], string.Format("Subsystems should not match {0} {1}", ssNot.ToString(), serialNum.SubSystemsDict[0].ToString())); Subsystem ss1 = new Subsystem("B", 1); Assert.AreEqual(ss1, serialNum.SubSystemsDict[1], string.Format("Subsystems do not match {0} {1}", ss1.ToString(), serialNum.SubSystemsDict[1].ToString())); Subsystem ss2 = new Subsystem("X", 2); Assert.AreEqual(ss2, serialNum.SubSystemsDict[2], string.Format("Subsystems do not match {0} {1}", ss2.ToString(), serialNum.SubSystemsDict[2].ToString())); Subsystem ss3 = new Subsystem("V", 3); Assert.AreEqual(ss3, serialNum.SubSystemsDict[3], string.Format("Subsystems do not match {0} {1}", ss3.ToString(), serialNum.SubSystemsDict[3].ToString())); Assert.AreEqual(1, serialNum.SystemSerialNumber, string.Format("Serial numbers do not match {0} {1}", 1, serialNum.SystemSerialNumber)); }
public void Test150KhzFrequency() { // Create a serial number string serialStr = "01K00000000000000000000000000001"; SerialNumber serialNum = new SerialNumber(serialStr); // Test the serial number Assert.AreEqual(serialStr, serialNum.ToString(), string.Format("Serial number strings did not match {0} {1}", serialStr, serialNum.ToString())); Assert.AreEqual(1, serialNum.SubSystemsList.Count, string.Format("Number of SubSystems did not match 1 {0}", serialNum.SubSystemsList.Count)); // Upper case K Subsystem ss = new Subsystem("K", 0); Assert.AreEqual(ss, serialNum.SubSystemsList[0], string.Format("Subsystems do not match {0} {1}", ss.ToString(), serialNum.SubSystemsList[0].ToString())); // Lower case k Subsystem ss1 = new Subsystem("k", 0); Assert.AreNotEqual(ss1, serialNum.SubSystemsList[0], string.Format("Subsystems should not match {0} {1}", ss1.ToString(), serialNum.SubSystemsList[0].ToString())); Assert.AreEqual(1, serialNum.SystemSerialNumber, string.Format("Serial numbers do not match {0} {1}", 1, serialNum.SystemSerialNumber)); }
public void TestChangeSerialBad() { // Create a serial number string serialStr = "01300000000000000000000000000001"; SerialNumber serial = new SerialNumber(serialStr); serial.SystemSerialNumber = 9999999; Assert.AreEqual(1, serial.SystemSerialNumber, "Sys Serial Number is incorrect."); Assert.AreEqual("01300000000000000000000000000001", serial.SerialNumberString, "Serial Number String is incorrect."); Assert.AreEqual("01300000000000000000000000000001", serial.ToString(), "ToString is incorrect."); }
public void TestChangeBaseHardwareBad() { // Create a serial number string serialStr = "01300000000000000000000000000001"; SerialNumber serial = new SerialNumber(serialStr); serial.BaseHardware = "22322323"; Assert.AreEqual("01", serial.BaseHardware, "BaseHardware is incorrect."); Assert.AreEqual("01300000000000000000000000000001", serial.SerialNumberString, "Serial Number String is incorrect."); Assert.AreEqual("01300000000000000000000000000001", serial.ToString(), "ToString is incorrect."); }
/// <summary> /// Determine if the given object is equal to this /// object. This will check the serial number strings /// to see if they match. /// </summary> /// <param name="obj">Object to compare with this object.</param> /// <returns>TRUE = serial number strings matched.</returns> public override bool Equals(object obj) { //Check for null and compare run-time types. if (obj == null || GetType() != obj.GetType()) { return(false); } SerialNumber p = (SerialNumber)obj; return(SerialNumberString == p.ToString()); }
public void TestBadSerial() { // Create a serial number string serialStr = "z"; SerialNumber serialNum = new SerialNumber(serialStr); // Test the serial number Assert.AreEqual(new SerialNumber().SerialNumberString, serialNum.ToString(), string.Format("Serial number strings did not match {0} {1}", new SerialNumber().SerialNumberString, serialNum.ToString())); Assert.AreEqual(0, serialNum.SubSystemsList.Count, string.Format("Number of SubSystems did not match 0 {0}", serialNum.SubSystemsList.Count)); Assert.AreEqual(0, serialNum.SystemSerialNumber, string.Format("Serial numbers do not match {0} {1}", 0, serialNum.SystemSerialNumber)); }
public void TestChangeSpare1() { // Create a serial number string serialStr = "01300000000000000000000000000001"; SerialNumber serial = new SerialNumber(serialStr); serial.Spare = "123456789"; Assert.AreEqual(1, serial.SystemSerialNumber, "Sys Serial Number is incorrect."); Assert.AreEqual("123456789", serial.Spare, "Spare is incorrect."); Assert.AreEqual("01300000000000000123456789000001", serial.SerialNumberString, "Serial Number String is incorrect."); Assert.AreEqual("01300000000000000123456789000001", serial.ToString(), "ToString is incorrect."); }
public void TestDualFrequency() { // Create a serial number string serialStr = "01340000000000000000000000000001"; SerialNumber serialNum = new SerialNumber(serialStr); // Test the serial number Assert.AreEqual(serialStr, serialNum.ToString(), string.Format("Serial number strings did not match {0} {1}", serialStr, serialNum.ToString())); Assert.AreEqual(2, serialNum.SubSystemsList.Count, string.Format("Number of SubSystems did not match 2 {0}", serialNum.SubSystemsList.Count)); Subsystem ss = new Subsystem("3", 0); Assert.AreEqual(ss, serialNum.SubSystemsList[0], string.Format("Subsystems do not match {0} {1}", ss.ToString(), serialNum.SubSystemsList[0].ToString())); Subsystem ss1 = new Subsystem("4", 1); Assert.AreEqual(ss1, serialNum.SubSystemsList[1], string.Format("Subsystems do not match {0} {1}", ss1.ToString(), serialNum.SubSystemsList[1].ToString())); Assert.AreEqual(1, serialNum.SystemSerialNumber, string.Format("Serial numbers do not match {0} {1}", 1, serialNum.SystemSerialNumber)); }
public void TestSerialJSON() { // Create a serial number string serialStr = "01300000000000000000000000000001"; SerialNumber serial = new SerialNumber(serialStr); // Convert to JSON and back string json = Newtonsoft.Json.JsonConvert.SerializeObject(serial); // Serialize object to JSON SerialNumber serialNum = Newtonsoft.Json.JsonConvert.DeserializeObject <SerialNumber>(json); // Deserialize the JSON // Test the serial number Assert.AreEqual(serialStr, serialNum.ToString(), string.Format("Serial number strings did not match {0} {1}", serialStr, serialNum.ToString())); Assert.AreEqual(1, serialNum.SubSystemsList.Count, string.Format("Number of SubSystems did not match 1 {0}", serialNum.SubSystemsList.Count)); Subsystem ss = new Subsystem("3", 0); Assert.AreEqual(ss, serialNum.SubSystemsList[0], string.Format("Subsystems do not match {0} {1}", ss.ToString(), serialNum.SubSystemsList[0].ToString())); Assert.AreEqual(1, serialNum.SystemSerialNumber, string.Format("Serial numbers do not match {0} {1}", 1, serialNum.SystemSerialNumber)); }
public void Test150KhzFrequency() { // Create a serial number string serialStr = "01K00000000000000000000000000001"; SerialNumber serialNum = new SerialNumber(serialStr); // Test the serial number Assert.AreEqual(serialStr, serialNum.ToString(), string.Format("Serial number strings did not match {0} {1}", serialStr, serialNum.ToString())); Assert.AreEqual(1, serialNum.SubSystemsDict.Count, string.Format("Number of SubSystems did not match 1 {0}", serialNum.SubSystemsDict.Count)); // Upper case K Subsystem ss = new Subsystem("K", 0); Assert.AreEqual(ss, serialNum.SubSystemsDict[0], string.Format("Subsystems do not match {0} {1}", ss.ToString(), serialNum.SubSystemsDict[0].ToString())); // Lower case k Subsystem ss1 = new Subsystem("k", 0); Assert.AreNotEqual(ss1, serialNum.SubSystemsDict[0], string.Format("Subsystems should not match {0} {1}", ss1.ToString(), serialNum.SubSystemsDict[0].ToString())); Assert.AreEqual(1, serialNum.SystemSerialNumber, string.Format("Serial numbers do not match {0} {1}", 1, serialNum.SystemSerialNumber)); }
public void TestMultipleSubsystems() { // Create a serial number string serialStr = "01KBXV00000000000000000000000001"; SerialNumber serialNum = new SerialNumber(serialStr); // Test the serial number Assert.AreEqual(serialStr, serialNum.ToString(), string.Format("Serial number strings did not match {0} {1}", serialStr, serialNum.ToString())); Assert.AreEqual(4, serialNum.SubSystemsList.Count, string.Format("Number of SubSystems did not match 4 {0}", serialNum.SubSystemsList.Count)); // Upper case K Subsystem ss = new Subsystem("K", 0); Assert.AreEqual(ss, serialNum.SubSystemsList[0], string.Format("Subsystems do not match {0} {1}", ss.ToString(), serialNum.SubSystemsList[0].ToString())); // Lower case K Subsystem ssNot = new Subsystem("k", 0); Assert.AreNotEqual(ssNot, serialNum.SubSystemsList[0], string.Format("Subsystems should not match {0} {1}", ssNot.ToString(), serialNum.SubSystemsList[0].ToString())); Subsystem ss1 = new Subsystem("B", 1); Assert.AreEqual(ss1, serialNum.SubSystemsList[1], string.Format("Subsystems do not match {0} {1}", ss1.ToString(), serialNum.SubSystemsList[1].ToString())); Subsystem ss2 = new Subsystem("X", 2); Assert.AreEqual(ss2, serialNum.SubSystemsList[2], string.Format("Subsystems do not match {0} {1}", ss2.ToString(), serialNum.SubSystemsList[2].ToString())); Subsystem ss3 = new Subsystem("V", 3); Assert.AreEqual(ss3, serialNum.SubSystemsList[3], string.Format("Subsystems do not match {0} {1}", ss3.ToString(), serialNum.SubSystemsList[3].ToString())); Assert.AreEqual(1, serialNum.SystemSerialNumber, string.Format("Serial numbers do not match {0} {1}", 1, serialNum.SystemSerialNumber)); }
public void TestChangeSpareBad() { // Create a serial number string serialStr = "01300000000000000000000000000001"; SerialNumber serial = new SerialNumber(serialStr); serial.Spare = "1234567890"; Assert.AreEqual(1, serial.SystemSerialNumber, "Sys Serial Number is incorrect."); Assert.AreEqual("000000000", serial.Spare, "Spare is incorrect."); Assert.AreEqual("01300000000000000000000000000001", serial.SerialNumberString, "Serial Number String is incorrect."); Assert.AreEqual("01300000000000000000000000000001", serial.ToString(), "ToString is incorrect."); }
public void TestChangeSerial() { // Create a serial number string serialStr = "01300000000000000000000000000001"; SerialNumber serial = new SerialNumber(serialStr); serial.SystemSerialNumber = 22; Assert.AreEqual(22, serial.SystemSerialNumber, "Sys Serial Number is incorrect."); Assert.AreEqual("01300000000000000000000000000022", serial.SerialNumberString, "Serial Number String is incorrect."); Assert.AreEqual("01300000000000000000000000000022", serial.ToString(), "ToString is incorrect."); }