コード例 #1
0
        public void replace_existing_action_data()
        {
            var storage   = new InMemoryActionCacheStorage();
            var idenifier = Guid.NewGuid().ToString("N");

            var code = storage.Store(new Object(), TimeSpan.FromDays(1), idenifier);

            storage.Store(new TestActionData(), TimeSpan.FromDays(1), idenifier);

            var retrieved = storage.TryRetrieve(code) as TestActionData;

            Assert.NotNull(retrieved);
        }
コード例 #2
0
        public void execute_action()
        {
            var storage = new InMemoryActionCacheStorage();
            var code    = storage.Store(new TestActionData(), TimeSpan.FromDays(1));

            var sut = GetServiceUnderTest(storage, new TestAction());

            var result = sut.ExecuteAsync(code).Result;

            Assert.Equal(true, result);
        }
コード例 #3
0
        public void execute_action_stored_data_removed()
        {
            var data    = new Dictionary <string, object>();
            var storage = new InMemoryActionCacheStorage(data);
            var code    = storage.Store(new TestActionData(), TimeSpan.FromDays(1));

            var sut = GetServiceUnderTest(storage, new TestAction());

            var _ = sut.ExecuteAsync(code).Result;

            Assert.DoesNotContain(code, data.Keys);
        }
コード例 #4
0
        public void execute_action_code_expired()
        {
            var storage = new InMemoryActionCacheStorage();
            var code    = storage.Store(new TestActionData(), TimeSpan.Zero);

            Thread.Sleep(500);

            var sut = GetServiceUnderTest(storage, new TestAction());

            var ex = Assert.Throws <AggregateException>(
                () => sut.ExecuteAsync(code).Result
                ).InnerException;

            Assert.Contains(code, ex.Message);
        }