Beispiel #1
0
        public void TestLoadPropertiesNoLocalization()
        {
            // Arrange

            // Act
            var result = ExpressionPropertiesHelper.LoadPropertyCollection <Person>();

            result.LoadProperties(null);

            // Assert
            Assert.IsNotNull(result);

            var result2 = result.ToList();

            Assert.IsTrue(result2.Any());

            Assert.IsTrue(result2.Any(x => x.Id == "Birth.Date"));

            Assert.IsTrue(result2.Any(x => x.Id == "Contacts[Type]"));


            var item = result2.FirstOrDefault();

            Assert.IsNotNull(item);
            Assert.IsNotNull(item.Id);
            Assert.IsNotNull(item.Name);

            //foreach (var itemx in result2)
            //{

            //    Debug.Print(itemx.Id);
            //}
        }
        public void TestConvertInput(Type type, string propertyId, string input, bool expectedValid)
        {
            // Arrange
            _coll = ExpressionPropertiesHelper.LoadPropertyCollection(type);


            //_coll = new ExpressionPropertyCollection<TItemType>();
            _coll.LoadProperties(null);

            // Act
            var result = _coll.ConvertInput(propertyId, input, out var isValid);



            // Assert
            Assert.AreEqual(expectedValid, isValid);

            if (isValid)
            {
                Assert.IsNotNull(result);
            }
            else
            {
                Assert.IsNull(result);
            }
        }
Beispiel #3
0
        public void TestLoadPropertiesWithLocalization(string cultureName)
        {
            var culture = CultureInfo.CreateSpecificCulture(cultureName);

            Thread.CurrentThread.CurrentCulture   = culture;
            Thread.CurrentThread.CurrentUICulture = culture;

            var loader     = ExpressionPropertiesHelper.LoadPropertyCollection <Person>();
            var properties = loader.LoadProperties(Bodoconsult.Core.ExpressionBuilder.Test.Resources.Person.ResourceManager);
            var ids        = properties.Select(p => p.Id);
            var names      = properties.Select(p => p.Name);

            Assert.That(ids, Is.EquivalentTo(propertyIds));

            Assert.That(names,
                        cultureName == "pt-BR" ? Is.EquivalentTo(propertyNamesptBr) : Is.EquivalentTo(propertyNames));
        }
        public void TestValidate(Type type, string propertyName, string input, bool expectedValid)
        {
            // Arrange
            _coll = ExpressionPropertiesHelper.LoadPropertyCollection(type);


            //_coll = new ExpressionPropertyCollection<TItemType>();
            _coll.LoadProperties(null);

            // Act
            var result = _coll.Validate(propertyName, input);


            foreach (var p in _coll.ToList())
            {
                Debug.Print(p.Id);
            }


            // Assert
            Assert.AreEqual(expectedValid, result);
        }
        public void TestLoadPropertiesNoResourceManager()
        {
            // Act
            _coll = ExpressionPropertiesHelper.LoadPropertyCollection(typeof(Person));
            _coll.LoadProperties(null);

            // Assert
            var count = _coll.Count;

            Assert.IsTrue(count > 0);


            var result = _coll.ToList();

            Assert.IsNotNull(result);
            Assert.AreEqual(count, result.Count);


            Assert.IsTrue(result.Any(x => x.Id == "Checker"));
            Assert.IsTrue(result.Any(x => x.Id == "Birth.Date"));
            Assert.IsTrue(result.Any(x => x.Id == "Money"));
            Assert.IsTrue(result.Any(x => x.Id == "Id"));
            Assert.IsTrue(result.Any(x => x.Id == "Name"));
        }