public void Char()
        {
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("Char"), entityFactory, new List <string>());

            Assert.Equal("c", actual.StringValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void ThrowOnInterface()
        {
            var actual = Record.Exception(() => EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("Interface"), entityFactory, new List <string>()));

            Assert.IsType <NotSupportedException>(actual);
            Assert.Equal("\"DasPoco.Interface\" has \"IHavePrettyFace\" as type, but that is just an interface and is therefore not supported", actual.Message);
        }
        public void ThrowOnUnsupportedTypes(string propertyName, System.Type type)
        {
            var actual = Record.Exception(() => EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty(propertyName), entityFactory, new List <string>()));

            Assert.IsType <NotSupportedException>(actual);
            Assert.Equal($"The type {type.Name} is not supported", actual.Message);
        }
        public void Byte()
        {
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("Byte"), entityFactory, new List <string>());

            Assert.Equal(5, actual.IntegerValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void NullPropertyInfoNotAllowed()
        {
            var actual = Record.Exception(() => EntityValueFactory.FromPropertyInfo(poco, null, entityFactory, new List <string>()));

            Assert.IsType <ArgumentNullException>(actual);
            Assert.Equal($"Cannot build an entity Value without a property{Environment.NewLine}Parameter name: prop", actual.Message);
        }
        public void Double()
        {
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("Double"), entityFactory, new List <string>());

            Assert.Equal(1.2, actual.DoubleValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void BoolFalse()
        {
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("False"), entityFactory, new List <string>());

            Assert.Equal(false, actual.BooleanValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void CharNullable_noValue()
        {
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("CharNullable"), entityFactory, new List <string>());

            Assert.Equal(true, actual.IsNull);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void TimeSpanNullable_hasValue()
        {
            poco.TimeSpanNullable = TimeSpan.FromDays(9.876);
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("TimeSpanNullable"), entityFactory, new List <string>());

            Assert.Equal(poco.TimeSpanNullable.Value.Ticks, actual.IntegerValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void TimeSpanX()
        {
            poco.TimeSpan = TimeSpan.FromDays(1.34567);
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("TimeSpan"), entityFactory, new List <string>());

            Assert.Equal(poco.TimeSpan.Ticks, actual.IntegerValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void DateTimeOffsetNullable_hasValue()
        {
            poco.DateTimeOffsetNullable = DateTimeOffset.UtcNow;
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("DateTimeOffsetNullable"), entityFactory, new List <string>());

            Assert.Equal(Timestamp.FromDateTimeOffset(poco.DateTimeOffsetNullable.Value), actual.TimestampValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void EnumNullable_hasValue()
        {
            poco.EnumNullable = DasPocoEnum.One;
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("EnumNullable"), entityFactory, new List <string>());

            Assert.Equal("One", actual.StringValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void FloatNullable_hasValue()
        {
            poco.FloatNullable = 1.2f;
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("FloatNullable"), entityFactory, new List <string>());

            Assert.Equal(1.2, actual.DoubleValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void BoolNullable_hasValue()
        {
            poco.BoolNullable = true;
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("BoolNullable"), entityFactory, new List <string>());

            Assert.Equal(true, actual.BooleanValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void LongNullable_hasValue()
        {
            poco.LongNullable = 8L;
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("LongNullable"), entityFactory, new List <string>());

            Assert.Equal(8L, actual.IntegerValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
        public void Binary()
        {
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("Binary"), entityFactory, new List <string>());

            var expected = ByteString.CopyFrom(poco.Binary, 0, poco.Binary.Length);

            Assert.Equal(expected, actual.BlobValue);
            Assert.Equal(true, actual.ExcludeFromIndexes);
        }
Example #17
0
        public void BoolNullable_noValue()
        {
            var prop  = poco.GetType().GetProperty("BoolNullable");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            Assert.Null(actual);
        }
Example #18
0
        public void BoolFalse()
        {
            var prop  = poco.GetType().GetProperty("False");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            Assert.IsType <bool>(actual);
            Assert.Equal(false, actual);
        }
Example #19
0
        public void Binary()
        {
            var prop  = poco.GetType().GetProperty("Binary");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            Assert.IsType <byte[]>(actual);
            Assert.Equal(poco.Binary, actual);
        }
Example #20
0
        public void Enum()
        {
            var prop  = poco.GetType().GetProperty("Enum");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            Assert.IsType <DasPocoEnum>(actual);
            Assert.Equal(DasPocoEnum.Two, actual);
        }
Example #21
0
        public void Double()
        {
            var prop  = poco.GetType().GetProperty("Double");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            Assert.IsType <double>(actual);
            Assert.Equal(1.2, actual);
        }
Example #22
0
        public void Long()
        {
            var prop  = poco.GetType().GetProperty("Long");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            Assert.IsType <long>(actual);
            Assert.Equal((long)-5, actual);
        }
Example #23
0
        public void Char()
        {
            var prop  = poco.GetType().GetProperty("Char");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            Assert.IsType <char>(actual);
            Assert.Equal('c', actual);
        }
        public void ArrayString()
        {
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("ArrayString"), entityFactory, new List <string>());

            Assert.Equal(3, actual.ArrayValue.Values.Count);
            Assert.Equal("one", actual.ArrayValue.Values[0].StringValue);
            Assert.Equal("two", actual.ArrayValue.Values[1].StringValue);
            Assert.Equal("three", actual.ArrayValue.Values[2].StringValue);
            Assert.Equal(false, actual.ExcludeFromIndexes);
        }
        public void ArrayInt()
        {
            var actual = EntityValueFactory.FromPropertyInfo(poco, poco.GetType().GetProperty("ArrayInt"), entityFactory, new List <string>());

            Assert.Equal(3, actual.ArrayValue.Values.Count);
            Assert.Equal(1, actual.ArrayValue.Values[0].IntegerValue);
            Assert.Equal(2, actual.ArrayValue.Values[1].IntegerValue);
            Assert.Equal(3, actual.ArrayValue.Values[2].IntegerValue);
            Assert.Equal(false, actual.ExcludeFromIndexes);
        }
Example #26
0
        public void Decimal()
        {
            var prop  = poco.GetType().GetProperty("Decimal");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            var actualDec = Assert.IsType <decimal>(actual);

            Assert.Equal(12345.0123456789012345m, actualDec, 15);
        }
 private void AddProperties(Entity entity, object poco, IList <string> recursionPath)
 {
     reflection
     .GetContentProperties(poco)
     .ForEach(prop =>
     {
         var name  = reflection.GetValueName(prop);
         var value = EntityValueFactory.FromPropertyInfo(poco, prop, this, recursionPath);
         entity.Properties.Add(name, value);
         recursionPath.Clear();
     });
 }
Example #28
0
        public void BoolNullable_hasValue()
        {
            poco.BoolNullable = true;
            var prop  = poco.GetType().GetProperty("BoolNullable");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            var typedActual = Assert.IsType <bool>(actual);

            Assert.Equal(true, typedActual);
        }
Example #29
0
        public void TimeSpanNullable_hasValue()
        {
            poco.TimeSpanNullable = TimeSpan.FromHours(789.123);
            var prop  = poco.GetType().GetProperty("TimeSpanNullable");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            var typedActual = Assert.IsType <TimeSpan>(actual);

            Assert.Equal(poco.TimeSpanNullable, typedActual);
        }
Example #30
0
        public void TimeSpanX()
        {
            poco.TimeSpan = TimeSpan.FromDays(1.34567);

            var prop  = poco.GetType().GetProperty("TimeSpan");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            Assert.IsType <TimeSpan>(actual);
            Assert.Equal(poco.TimeSpan, actual);
        }