public void findUnSentMessagesTest() { MessageCache messageCache = new MessageCache(); SniperInfo sniperInfo = new SniperInfo(); sniperInfo.latitude = 1; sniperInfo.longitude = 2; sniperInfo.timeStamp = DateTime.Now.AddMilliseconds(100); SniperInfo sniperInfo2= new SniperInfo(); sniperInfo2.latitude = 1; sniperInfo2.longitude = 2; SniperInfo differntSniperInfo = new SniperInfo(); differntSniperInfo.latitude = 4; differntSniperInfo.longitude = 5; differntSniperInfo.timeStamp = DateTime.Now.AddMilliseconds(100); List<SniperInfo> unsentMessages = messageCache.findUnSentMessages(new List<SniperInfo>() { sniperInfo }); Assert.IsNotNull(unsentMessages); Assert.AreEqual(1, unsentMessages.Count); unsentMessages = messageCache.findUnSentMessages(new List<SniperInfo>() { sniperInfo2 }); Assert.IsNotNull(unsentMessages); Assert.AreEqual(0, unsentMessages.Count); unsentMessages = messageCache.findUnSentMessages(new List<SniperInfo>() { differntSniperInfo }); Assert.IsNotNull(unsentMessages); Assert.AreEqual(1, unsentMessages.Count); Thread.Sleep(110); unsentMessages = messageCache.findUnSentMessages(new List<SniperInfo>() { sniperInfo2 }); Assert.IsNotNull(unsentMessages); Assert.AreEqual(1, unsentMessages.Count); }
public void FindUnSentMessagesTest() { var messageCache = new MessageCache(); var sniperInfo = new SniperInfo { Latitude = 1, Longitude = 2, ExpirationTimestamp = DateTime.Now.AddMilliseconds(100) }; var sniperInfo2 = new SniperInfo { Latitude = 1, Longitude = 2 }; var differntSniperInfo = new SniperInfo { Latitude = 4, Longitude = 5, ExpirationTimestamp = DateTime.Now.AddMilliseconds(100) }; var unsentMessages = messageCache.FindUnSentMessages(new List<SniperInfo> {sniperInfo}); Assert.IsNotNull(unsentMessages); Assert.AreEqual(1, unsentMessages.Count); unsentMessages = messageCache.FindUnSentMessages(new List<SniperInfo> {sniperInfo2}); Assert.IsNotNull(unsentMessages); Assert.AreEqual(0, unsentMessages.Count); unsentMessages = messageCache.FindUnSentMessages(new List<SniperInfo> {differntSniperInfo}); Assert.IsNotNull(unsentMessages); Assert.AreEqual(1, unsentMessages.Count); Thread.Sleep(110); unsentMessages = messageCache.FindUnSentMessages(new List<SniperInfo> {sniperInfo2}); Assert.IsNotNull(unsentMessages); Assert.AreEqual(1, unsentMessages.Count); }