Пример #1
0
            private void ShouldThrowIfTheRootKeyPointsToASingleValue()
            {
                _parserMock
                .Setup(p => p.Parse(It.IsAny <Stream>()))
                .Returns(new Dictionary <string, string> {
                    { string.Empty, "value" }
                });
                var kvPair = new KVPair("rootKey")
                {
                    Value = new byte[]
                    {
                        1
                    }
                };

                Func <IEnumerable <KeyValuePair <string, string> > > converting =
                    () => kvPair.ConvertToConfig("rootKey", _parserMock.Object);

                converting
                .Enumerating()
                .Should()
                .Throw <Exception>()
                .WithMessage(
                    "The key must not be null or empty. Ensure that there is at least one key under the root of the config or that the data there contains more than just a single value.");
            }
Пример #2
0
            private void ShouldConvertKVPairToConfigCorrectly(
                string rootKey,
                string kvPairKey,
                Dictionary <string, string> parsedConfig,
                IEnumerable <KeyValuePair <string, string> > expected)
            {
                _parserMock
                .Setup(p => p.Parse(It.IsAny <Stream>()))
                .Returns(parsedConfig);
                var kvPair = new KVPair(kvPairKey)
                {
                    Value = new byte[]
                    {
                        1
                    }
                };

                var config = kvPair.ConvertToConfig(rootKey, _parserMock.Object);

                config.Should().BeEquivalentTo(expected);
            }