コード例 #1
0
        public void Get()
        {
            var sut = new CorrelationCache<int>();
            var corrId = Guid.NewGuid();
            sut.Add(corrId, 42);
            Assert.AreEqual(42, sut.Get(corrId));

            Assert.Throws<InvalidOperationException>(() => sut.Get(Guid.NewGuid()));
        }
コード例 #2
0
        public void Get()
        {
            var sut    = new CorrelationCache <int>();
            var corrId = Guid.NewGuid();

            sut.Add(corrId, 42);
            Assert.AreEqual(42, sut.Get(corrId));

            Assert.Throws <InvalidOperationException>(() => sut.Get(Guid.NewGuid()));
        }
コード例 #3
0
        public void Add()
        {
            var sut = new CorrelationCache<int>();
            var corrId = Guid.NewGuid();
            var now = DateTime.Now;
            sut.Add(corrId, 42);

            Assert.AreEqual(1, sut._cache.Count());
            Assert.AreEqual(corrId, sut._cache[0].CorrelationId);
            Assert.AreEqual(42, sut._cache[0].Data);
            Assert.IsTrue(sut._cache[0].ExpiresAt.Subtract(now).TotalSeconds > 58 && sut._cache[0].ExpiresAt.Subtract(now).TotalSeconds < 62);
        }
コード例 #4
0
        public void Add()
        {
            var sut    = new CorrelationCache <int>();
            var corrId = Guid.NewGuid();
            var now    = DateTime.Now;

            sut.Add(corrId, 42);

            Assert.AreEqual(1, sut._cache.Count());
            Assert.AreEqual(corrId, sut._cache[0].CorrelationId);
            Assert.AreEqual(42, sut._cache[0].Data);
            Assert.IsTrue(sut._cache[0].ExpiresAt.Subtract(now).TotalSeconds > 58 && sut._cache[0].ExpiresAt.Subtract(now).TotalSeconds < 62);
        }