public void ReturnsAnUnknownDeviceWhenNotExpected() { var serviceLocator = new Mock <IServiceProvider>(); var target = new DeviceTypeFactory(serviceLocator.Object); var result = target.Create("unknown-name", "unknown-device"); Assert.IsInstanceOf <Unknown>(result); var device = (Unknown)result; Assert.AreEqual("unknown-name", device.Name); Assert.AreEqual("unknown-device", device.DeviceType); }
public void Demo5() { JT808GlobalConfig.Instance .Register(Assembly.GetCallingAssembly()); JT808Package jT808Package = JT808MsgId.位置信息汇报.Create("123456789012", new JT808_0x0200 { AlarmFlag = 1, Altitude = 40, GPSTime = DateTime.Parse("2018-12-20 20:10:10"), Lat = 12222222, Lng = 132444444, Speed = 60, Direction = 0, StatusFlag = 2, JT808CustomLocationAttachData = new Dictionary <byte, JT808_0x0200_CustomBodyBase> { { 0x81, new JT808_0x0200_DT1_0x81 { Age = 15, Gender = 1, UserName = "******" } } } }); byte[] data = JT808Serializer.Serialize(jT808Package); var jT808PackageResult = JT808Serializer.Deserialize <JT808Package>(data); JT808_0x0200 jT808_0X0200 = jT808PackageResult.Bodies as JT808_0x0200; var attach = DeviceTypeFactory.Create(cache[jT808PackageResult.Header.TerminalPhoneNo], jT808_0X0200.JT808CustomLocationAttachOriginalData); var extJson = attach.ExtData.Data.ToString(Formatting.None); var attachinfo81 = (JT808_0x0200_DT1_0x81)attach.JT808CustomLocationAttachData[0x81]; Assert.Equal((uint)15, attachinfo81.Age); Assert.Equal(1, attachinfo81.Gender); Assert.Equal("smallchi", attachinfo81.UserName); }