public void FromBinary_should_return_correct_token() { // Arrange var tokenBytes = new byte[] { 0xfe, 0x58, 0xfc, 0x8f, 0x52, 0x7c, 0x36, 0x3d, 0x1b, 0x77, 0x5d, 0xca, 0x13, 0x3e, 0x04, 0xbf, 0xf2, 0x4d, 0xc5, 0x03, 0x2d, 0x08, 0x83, 0x69, 0x92, 0x39, 0x5c, 0xc5, 0x6b, 0xfa, 0x62, 0xef }; // Act var token = DeviceToken.FromBinary(tokenBytes); // Assert Assert.AreEqual("fe58fc8f527c363d1b775dca133e04bff24dc5032d08836992395cc56bfa62ef", token.ToString()); }
private IFeedbackTuple ParseFromByteArray(byte[] bytes) { int offset = 0; // first four bytes var time_t = BitConverter.ToInt32(bytes, offset); offset += 4; // second two bytes var tokenLen = BitConverter.ToInt16(bytes, offset); offset += 2; // remaning is the token in binary form var tokenBytes = bytes.Skip(offset).Take(tokenLen).ToArray(); return(new FeedbackTuple(DateTime.FromBinary(time_t), DeviceToken.FromBinary(tokenBytes))); }