public void DontThrowArgumentExceptionForEmptyDictionary()
        {
            var emptyDictionary = new Dictionary <string, object>();
            var ex = Record.Exception(() => StartBitFormatter.FormatAsCypherText(emptyDictionary, null));

            ex.Should().BeNull();
        }
        public void ThrowArgumentExceptionForNullValue()
        {
            var startBits = new { foo = (object)null };

            Assert.Throws <ArgumentException>(
                () => StartBitFormatter.FormatAsCypherText(startBits, null)
                );
        }
        public void ThrowNotSupportedExceptionForUnknownType()
        {
            var badObject = new { n1 = new StartBitFormatterTests() };

            Assert.Throws <NotSupportedException>(
                () => StartBitFormatter.FormatAsCypherText(badObject, null)
                );
        }
        public void DontThrowArgumentExceptionForEmptyDictionary()
        {
            var emptyDictionary = new Dictionary <string, object>();

            Assert.DoesNotThrow(
                () => StartBitFormatter.FormatAsCypherText(emptyDictionary, null)
                );
        }
        public void ArgumentExceptionForNullValueIncludesPropertyName()
        {
            var startBits = new { foo = (object)null };
            var ex        = Assert.Throws <ArgumentException>(
                () => StartBitFormatter.FormatAsCypherText(startBits, null)
                );

            Assert.Contains("foo", ex.Message);
        }
        public void NotSupportedExceptionForUnknownTypeIncludesTypeName()
        {
            var badObject = new { n1 = new StartBitFormatterTests() };
            var exception = Assert.Throws <NotSupportedException>(
                () => StartBitFormatter.FormatAsCypherText(badObject, null)
                );

            Assert.Contains(typeof(StartBitFormatterTests).FullName, exception.Message);
        }
        public void ThrowArgumentExceptionForEmptyObject()
        {
            var emptyObject = new {};
            var ex          = Assert.Throws <ArgumentException>(
                () => StartBitFormatter.FormatAsCypherText(emptyObject, null)
                );

            Assert.Equal("startBits", ex.ParamName);
        }
        public void NotSupportedExceptionForUnknownTypeIncludesIdentityName()
        {
            var badObject = new { n1 = new StartBitFormatterTests() };
            var exception = Assert.Throws <NotSupportedException>(
                () => StartBitFormatter.FormatAsCypherText(badObject, null)
                );

            StringAssert.Contains("n1", exception.Message);
        }
        static CypherQuery ToCypher(object startBits)
        {
            var parameters = new Dictionary <string, object>();
            Func <object, string> createParameter = value =>
            {
                var name = "p" + parameters.Count;
                parameters.Add(name, value);
                return(string.Format("{{{0}}}", name));
            };

            var cypherText = StartBitFormatter.FormatAsCypherText(startBits, createParameter);

            var query = new CypherQuery(cypherText, parameters, CypherResultMode.Projection, CypherResultFormat.Rest);

            return(query);
        }
Example #10
0
        private static CypherQuery ToCypher(object startBits)
        {
            var parameters = new Dictionary <string, object>();

            string CreateParameter(object value)
            {
                var name = "p" + parameters.Count;

                parameters.Add(name, value);
                return($"${name}");
            }

            var cypherText = StartBitFormatter.FormatAsCypherText(startBits, CreateParameter);

            var query = new CypherQuery(cypherText, parameters, CypherResultMode.Projection, CypherResultFormat.Rest, "neo4j");

            return(query);
        }