public void InsertRange()
        {
            var db = new MemoryDatabase <string, int>();
            var kt = new MockTransformer();
            var vt = new MockTransformer();

            var tdb = new TransformDatabase <string, int, int, string>
                      (
                db: db,
                keyTransformer: new ReverseTransformer <string, int>(kt),
                valueTransformer: vt
                      );

            tdb.InsertRange(new KeyValuePair <int, string>[]
            {
                new KeyValuePair <int, string>(1, "a"),
                new KeyValuePair <int, string>(2, "b"),
                new KeyValuePair <int, string>(3, "c"),
            });

            db.EnumerateAggressively(3)
            .Should()
            .BeEquivalentTo(new KeyValuePair <string, int>[]
            {
                new KeyValuePair <string, int>(kt.TransformPre(1), vt.TransformPost("a")),
                new KeyValuePair <string, int>(kt.TransformPre(2), vt.TransformPost("b")),
                new KeyValuePair <string, int>(kt.TransformPre(3), vt.TransformPost("c")),
            });
        }
Пример #2
0
        public TransformerDatabaseTests()
        {
            _memoryDatabase   = new MemoryDatabase <string, int>();
            _keyTransformer   = new MockTransformer();
            _valueTransformer = new MockTransformer();

            _transformDatabase = new TransformDatabase <string, int, int, string>
                                 (
                db: _memoryDatabase,
                keyTransformer: _keyTransformer.Reverse(),
                valueTransformer: _valueTransformer
                                 );

            _values = new[]
            {
                KeyValuePair.Create(1, "a"),
                KeyValuePair.Create(2, "b"),
                KeyValuePair.Create(3, "c"),
            };

            _expectValues = _values
                            .Select
                            (
                x => KeyValuePair.Create
                (
                    _keyTransformer.TransformPre(x.Key),
                    _valueTransformer.TransformPost(x.Value)
                )
                            )
                            .ToArray();
        }