Esempio n. 1
0
        public void TryFetch_WithNullInPath_ReturnsDefaultValue()
        {
            var obj = new TestClass0();

            bool   result0 = obj.TryFetch(o => o.Class1.BoolProperty);
            long   result1 = obj.TryFetch(o => o.Class1.LongProperty);
            string result2 = obj.TryFetch(o => o.Class1.ToString());

            Assert.That(result0, Is.False);
            Assert.That(result1, Is.EqualTo(0));
            Assert.That(result2, Is.Empty);
        }
        public void TryFetch_WithMethodCall_ReturnsValue()
        {
            var obj = new TestClass0 {StringProperty = Any.String};

            string result = obj.TryFetch(o => o.GetString());

            Assert.That(result, Is.EqualTo(Any.String));
        }
        public void TryFetch_WithMethodCallWithArgument_ReturnsValue()
        {
            var obj = new TestClass0();

            string result = obj.TryFetch(o => o.ConvertToString(Any.Int));

            Assert.That(result, Is.EqualTo(Any.Int.ToString()));
        }
        public void TryFetch_WithMethodCallLambda_ReturnsValue()
        {
            var obj = new TestClass0();

            int result = obj.TryFetch(o => o.Ints.Single(i => i == Any.Int));

            Assert.That(result, Is.EqualTo(Any.Int));
        }
        public void TryFetch_WithExtensionMethod_ReturnsValue()
        {
            var obj = new TestClass0();

            var result = obj.TryFetch(o => o.Ints.ToList());

            Assert.That(result.Count(), Is.EqualTo(2));
        }
Esempio n. 6
0
        public void TryFetch_WithMethodCallWithArgument_ReturnsValue()
        {
            var obj = new TestClass0();

            string result = obj.TryFetch(o => o.ConvertToString(Any.Int));

            Assert.That(result, Is.EqualTo(Any.Int.ToString()));
        }
Esempio n. 7
0
        public void TryFetch_WithMethodCallLambda_ReturnsValue()
        {
            var obj = new TestClass0();

            int result = obj.TryFetch(o => o.Ints.Single(i => i == Any.Int));

            Assert.That(result, Is.EqualTo(Any.Int));
        }
Esempio n. 8
0
        public void TryFetch_WithExtensionMethod_ReturnsValue()
        {
            var obj = new TestClass0();

            var result = obj.TryFetch(o => o.Ints.ToList());

            Assert.That(result.Count(), Is.EqualTo(2));
        }
Esempio n. 9
0
        public void TryFetch_WithMethodCall_ReturnsValue()
        {
            var obj = new TestClass0 {
                StringProperty = Any.String
            };

            string result = obj.TryFetch(o => o.GetString());

            Assert.That(result, Is.EqualTo(Any.String));
        }
Esempio n. 10
0
        public void TryFetch_WithStringProperty_ReturnsValueAsString()
        {
            const string expected = Any.String;
            var          obj      = new TestClass0 {
                Class1 = new TestClass1 {
                    StringProperty = expected
                }
            };

            var result = obj.TryFetch(o => o.Class1.StringProperty);

            Assert.That(result, Is.EqualTo(expected));
        }
Esempio n. 11
0
        public void TryFetch_WithObjectGraph_ReturnsValueAsString()
        {
            var obj = new TestClass0
            {
                Class1 =
                    new TestClass1
                {
                    Class0 = new TestClass0 {
                        Class1 = new TestClass1 {
                            StringProperty = Any.OtherString
                        }
                    }
                }
            };

            string result = obj.TryFetch(o => o.Class1.Class0.Class1.StringProperty);

            Assert.That(result, Is.EqualTo(Any.OtherString));
        }
        public void TryFetch_WithNullInPath_ReturnsDefaultValue()
        {
            var obj = new TestClass0();

            bool result0 = obj.TryFetch(o => o.Class1.BoolProperty);
            long result1 = obj.TryFetch(o => o.Class1.LongProperty);
            string result2 = obj.TryFetch(o => o.Class1.ToString());

            Assert.That(result0, Is.False);
            Assert.That(result1, Is.EqualTo(0));
            Assert.That(result2, Is.Empty);
        }
        public void TryFetch_WithStringProperty_ReturnsValueAsString()
        {
            const string expected = Any.String;
            var obj = new TestClass0 {Class1 = new TestClass1 {StringProperty = expected}};

            var result = obj.TryFetch(o => o.Class1.StringProperty);

            Assert.That(result, Is.EqualTo(expected));
        }
        public void TryFetch_WithObjectGraph_ReturnsValueAsString()
        {
            var obj = new TestClass0
                {
                    Class1 =
                        new TestClass1
                            {
                                Class0 = new TestClass0 {Class1 = new TestClass1 {StringProperty = Any.OtherString}}
                            }
                };

            string result = obj.TryFetch(o => o.Class1.Class0.Class1.StringProperty);

            Assert.That(result, Is.EqualTo(Any.OtherString));
        }