public void GivenGenericState_WhenCached_Retrieve()
        {
            // Arrange
            var stateCacheService = new StateCacheService();

            // Act
            stateCacheService.Count.Should().Be(0);
            Envelope <KeyValue> saveState = stateCacheService.GetOrCreate(() => new Envelope <KeyValue>("first", new KeyValue("key1", "value1")));

            // Assert
            stateCacheService.Count.Should().Be(1);
            Envelope <KeyValue> test = (Envelope <KeyValue>)stateCacheService.Select(x => x.Value).First();

            stateCacheService.TryGetValue <Envelope <KeyValue> >(out Envelope <KeyValue> value2).Should().BeTrue();

            value2.Name.Should().Be("first");
            value2.Value.Key.Should().Be("key1");
            value2.Value.Value.Should().Be("value1");
        }
        public void GivenSingleState_WhenCached_Retrieve()
        {
            // Arrange
            var stateCacheService = new StateCacheService();
            var state             = new KeyValue("key1", "value1");

            // Act
            stateCacheService.Count.Should().Be(0);
            KeyValue saveState = stateCacheService.GetOrCreate(() => new KeyValue("key1", "value1"));

            // Assert
            stateCacheService.Count.Should().Be(1);
            KeyValue test = (KeyValue)stateCacheService.Select(x => x.Value).First();

            (test == state).Should().BeTrue();

            stateCacheService.TryGetValue <KeyValue>(out KeyValue value2).Should().BeTrue();

            KeyValue saveState2 = stateCacheService.GetOrCreate(() => new KeyValue("key2", "value2"));

            (saveState2 == state).Should().BeTrue();
        }