public void CheckTokenPairRecordCreation() { // arrange // 0 128 48 0 0 0 0 4 // 0000|0000|10 00|0000|0011| 0000|0000|0000|0000|0000|0000|0000|0000|0000|0000|0100 // 2 3 4 var token1 = new InstrumentationLib.Token(2, 3, 4); // 0 128 48 0 0 0 0 5 // 0000|0000|10 00|0000|0011| 0000|0000|0000|0000|0000|0000|0000|0000|0000|0000|0101 // 2 3 5 const long timestamp = (long)0x00ee0000000000ff; byte[] ba = { 4, 0, 0, 0, 0, 48, 128, 0, 5, 0, 0, 0, 0, 48, 128, 0, 0xff, 0, 0, 0, 0, 0, 0xee, 0 }; // act var record = new InstrumentationLib.TokenPairRecord(ba, 0); // assert Assert.AreEqual((short)2, record.T1.AppId); Assert.AreEqual((byte)3, record.T1.EventId); Assert.AreEqual((ulong)4, record.T1.Id); Assert.AreEqual((short)2, record.T2.AppId); Assert.AreEqual((byte)3, record.T2.EventId); Assert.AreEqual((ulong)5, record.T2.Id); Assert.AreEqual(timestamp, record.Ts); }
public void CheckTokenCreation1() { // arrange // act var token = new InstrumentationLib.Token(2, 3, 456); // assert Assert.AreEqual(2, token.AppId); Assert.AreEqual(3, token.EventId); Assert.AreEqual((ulong)456, token.Id); }
public void CheckAddEvent() { // arrange // act var token = new InstrumentationLib.Token(2, 3, 456) { EventId = 4 }; // assert Assert.AreEqual(2, token.AppId); Assert.AreEqual(4, token.EventId); Assert.AreEqual((ulong)456, token.Id); }
public void CheckTokenCreation2() { // arrange // 0 128 48 0 0 0 1 200 // 0000|0000|10 00|0000|0011| 0000|0000|0000|0000|0000|0000|0000|0000|0001|1100|1000 // 2 3 456 byte[] ba = { 200, 1, 0, 0, 0, 48, 128, 0 }; var token = new InstrumentationLib.Token(2, 3, 456); // act var token2 = new InstrumentationLib.Token(ba); // assert Assert.AreEqual(2, token2.AppId); Assert.AreEqual(3, token2.EventId); Assert.AreEqual((ulong)456, token2.Id); }
public void CheckToByteArray() { // arrange // 0 128 48 0 0 0 0 4 // 0000|0000|10 00|0000|0011| 0000|0000|0000|0000|0000|0000|0000|0000|0000|0000|0100 // 2 3 4 var token1 = new InstrumentationLib.Token(2, 3, 4); // 0 128 48 0 0 0 0 5 // 0000|0000|10 00|0000|0011| 0000|0000|0000|0000|0000|0000|0000|0000|0000|0000|0101 // 2 3 5 var token2 = new InstrumentationLib.Token(2, 3, 5); const long timestamp = (long)0x00ee0000000000ff; InstrumentationLib.Moles.MTokenPairRecord.AllInstances.TimerTicksPerMicroGet = (_) => { return 1.0; }; var record = new InstrumentationLib.TokenPairRecord(token1, token2, timestamp); // act byte[] ba = record.ToByteArray(); // assert // Token1 Assert.AreEqual(0, ba[7]); Assert.AreEqual(128, ba[6]); Assert.AreEqual(48, ba[5]); Assert.AreEqual(0, ba[4]); Assert.AreEqual(0, ba[3]); Assert.AreEqual(0, ba[2]); Assert.AreEqual(0, ba[1]); Assert.AreEqual(4, ba[0]); // Token2 Assert.AreEqual(0, ba[15]); Assert.AreEqual(128, ba[14]); Assert.AreEqual(48, ba[13]); Assert.AreEqual(0, ba[12]); Assert.AreEqual(0, ba[11]); Assert.AreEqual(0, ba[10]); Assert.AreEqual(0, ba[9]); Assert.AreEqual(5, ba[8]); // Timestamp Assert.AreEqual(0, ba[23]); Assert.AreEqual(0xee, ba[22]); Assert.AreEqual(0, ba[21]); Assert.AreEqual(0, ba[20]); Assert.AreEqual(0, ba[19]); Assert.AreEqual(0, ba[18]); Assert.AreEqual(0, ba[17]); Assert.AreEqual(0xff, ba[16]); }
public void CheckToByteArray() { // arrange // 0 128 48 0 0 0 0 4 // 0000|0000|10 00|0000|0011| 0000|0000|0000|0000|0000|0000|0000|0000|0000|0000|0100 // 2 3 4 var token = new InstrumentationLib.Token(2, 3, 4); // act byte[] ba = token.ToByteArray(); // assert Assert.AreEqual(0, ba[7]); Assert.AreEqual(128, ba[6]); Assert.AreEqual(48, ba[5]); Assert.AreEqual(0, ba[4]); Assert.AreEqual(0, ba[3]); Assert.AreEqual(0, ba[2]); Assert.AreEqual(0, ba[1]); Assert.AreEqual(4, ba[0]); }
public void CheckTokenCreationWithBadLength() { // arrange var token = new InstrumentationLib.Token(2, 3, 456); byte[] ba = token.ToByteArray(); // act var token2 = new InstrumentationLib.Token(ba, 3); // assert }
public void CheckTokenCreation3() { // arrange // 0 128 48 0 0 0 0 4 // 0000|0000|10 00|0000|0011| 0000|0000|0000|0000|0000|0000|0000|0000|0000|0000|0100 // 2 3 4 byte[] ba = {4,0,0,0,0,48,128,0}; // act var token = new InstrumentationLib.Token(ba, 0); // assert Assert.AreEqual(2, token.AppId); Assert.AreEqual(3, token.EventId); Assert.AreEqual((ulong)4, token.Id); }