Пример #1
0
        public async Task Should_support_access_to_eventual_success()
        {
            IIndex <string, SimpleValue> index = new GreenCache <SimpleValue>().AddIndex("id", x => x.Id);

            var helloKey = "Hello";

            Task <SimpleValue> valueTask = index.Get(helloKey, SimpleValueFactory.Faulty);

            Task <SimpleValue> goodValueTask = index.Get(helloKey, SimpleValueFactory.Healthy);

            Task <SimpleValue> readValueTask = index.Get(helloKey);

            Assert.That(async() => await valueTask, Throws.TypeOf <TestException>());

            var value = await goodValueTask;

            Assert.That(value, Is.Not.Null);
            Assert.That(value.Id, Is.EqualTo(helloKey));
            Assert.That(value.Value, Is.EqualTo("The key is Hello"));

            var readValue = await readValueTask;

            Assert.That(readValue, Is.Not.Null);
            Assert.That(readValue.Id, Is.EqualTo(helloKey));
            Assert.That(readValue.Value, Is.EqualTo("The key is Hello"));
        }
Пример #2
0
        public async Task Should_not_find_a_faulted_value()
        {
            IIndex <string, SimpleValue> index = new GreenCache <SimpleValue>().AddIndex("id", x => x.Id);

            var helloKey = "Hello";

            Task <SimpleValue> valueTask = index.Get(helloKey, SimpleValueFactory.Faulty);

            Assert.That(async() => await valueTask, Throws.TypeOf <TestException>());

            Assert.That(async() => await index.Get(helloKey), Throws.TypeOf <KeyNotFoundException>());
        }
Пример #3
0
        public async Task Should_support_a_simple_addition_and_access()
        {
            IIndex <string, SimpleValue> index = new GreenCache <SimpleValue>().AddIndex("id", x => x.Id);

            var helloKey = "Hello";

            var value = await index.Get(helloKey, SimpleValueFactory.Healthy);

            Task <SimpleValue> readValueTask = index.Get(helloKey);

            Assert.That(value, Is.Not.Null);
            Assert.That(value.Id, Is.EqualTo(helloKey));
            Assert.That(value.Value, Is.EqualTo("The key is Hello"));

            var readValue = await readValueTask;

            Assert.That(readValue, Is.Not.Null);
            Assert.That(readValue.Id, Is.EqualTo(helloKey));
            Assert.That(readValue.Value, Is.EqualTo("The key is Hello"));
        }
Пример #4
0
        public async Task Should_support_a_simple_addition()
        {
            var index = new GreenCache <SimpleValue>().AddIndex("id", x => x.Id);

            var helloKey = "Hello";

            var value = await index.Get(helloKey, SimpleValueFactory.Healthy);

            Assert.That(value, Is.Not.Null);
            Assert.That(value.Id, Is.EqualTo(helloKey));
            Assert.That(value.Value, Is.EqualTo("The key is Hello"));
        }