public void TestSimplePolling_SetGet_And_Then_Get_ReturnsNull()
        {
            var polling = new SimplePolling();

            polling.Set("Test");

            var result = polling.TryGet();

            Assert.AreEqual("Test", result);

            var anotherAttempt = polling.TryGet();

            Assert.IsNull(anotherAttempt);
        }
        public void TestSimplePolling_GetNeverSet_ReturnsNull()
        {
            var polling = new SimplePolling();

            var result = polling.TryGet();

            Assert.IsNull(result);
        }
        public void TestSimplePolling_GetSet_Success()
        {
            var polling = new SimplePolling();

            polling.Set("Test");

            var result = polling.TryGet();

            Assert.AreEqual("Test", result);
        }
Example #4
0
        public string Get()
        {
            DateTime limit = DateTime.UtcNow.AddMinutes(1);

            while (DateTime.UtcNow < limit)
            {
                var value = _simplePolling.TryGet();

                if (value != null)
                {
                    return(value);
                }
            }

            return("Timeout");
        }