Exemplo n.º 1
0
        public void Complete()
        {
            // arrange
            var resultMap = new ResultMap();

            resultMap.EnsureCapacity(5);

            // act
            resultMap.SetValue(0, "abc1", "def");
            resultMap.SetValue(2, "abc2", "def");
            resultMap.SetValue(4, "abc3", "def");
            resultMap.Complete();

            // assert
            Assert.Collection(
                (IEnumerable <ResultValue>)resultMap,
                t =>
            {
                Assert.Equal("abc1", t.Name);
                Assert.Equal("def", t.Value);
            },
                t =>
            {
                Assert.Equal("abc2", t.Name);
                Assert.Equal("def", t.Value);
            },
                t =>
            {
                Assert.Equal("abc3", t.Name);
                Assert.Equal("def", t.Value);
            });
        }
Exemplo n.º 2
0
        public void GetValue_ValueIsFound(int capacity)
        {
            // arrange
            var resultMap = new ResultMap();

            resultMap.EnsureCapacity(capacity);
            resultMap.SetValue(0, "abc", "def");
            resultMap.SetValue(1, "def", "def");
            resultMap.SetValue(2, "ghi", "def");

            // act
            ResultValue value = resultMap.GetValue("def", out int index);

            // assert
            Assert.Equal("def", value.Name);
            Assert.Equal(1, index);
        }
Exemplo n.º 3
0
        public void ContainsKey(int capacity)
        {
            // arrange
            var resultMap = new ResultMap();

            resultMap.EnsureCapacity(capacity);
            resultMap.SetValue(0, "abc", "def");
            resultMap.SetValue(capacity / 2, "def", "def");
            resultMap.SetValue(capacity - 1, "ghi", "def");

            IReadOnlyDictionary <string, object> dict = resultMap;

            // act
            var found = dict.ContainsKey("def");

            // assert
            Assert.True(found);
        }
Exemplo n.º 4
0
        public void TryGetValue_ValueIsFound(int capacity)
        {
            // arrange
            var resultMap = new ResultMap();

            resultMap.EnsureCapacity(capacity);
            resultMap.SetValue(0, "abc", "def");
            resultMap.SetValue(capacity / 2, "def", "def");
            resultMap.SetValue(capacity - 1, "ghi", "def");

            IReadOnlyDictionary <string, object> dict = resultMap;

            // act
            var found = dict.TryGetValue("def", out var value);

            // assert
            Assert.True(found);
            Assert.Equal("def", value);
        }
Exemplo n.º 5
0
        public void EnumerateValues()
        {
            // arrange
            var resultMap = new ResultMap();

            resultMap.EnsureCapacity(5);

            // act
            resultMap.SetValue(0, "abc1", "def");
            resultMap.SetValue(2, "abc2", "def");
            resultMap.SetValue(4, "abc3", "def");

            // assert
            Assert.Collection(
                ((IReadOnlyDictionary <string, object>)resultMap).Values,
                t => Assert.Equal("def", t),
                t => Assert.Equal("def", t),
                t => Assert.Equal("def", t));
        }
Exemplo n.º 6
0
        public void BuildResult_SimpleResultSet_SnapshotMatches()
        {
            // arrange
            var       helper = new ResultHelper(CreatePool());
            ResultMap map    = helper.RentResultMap(1);

            map.SetValue(0, "abc", "def", false);
            helper.SetData(map);

            // act
            IQueryResult result = helper.BuildResult();

            // assert
            result.ToJson().MatchSnapshot();
        }