コード例 #1
0
        public void CanPopulateSpecificFieldInExistingObject()
        {
            var myObject    = new ExampleClass();
            var observe1    = myObject.AStringFromFile;
            var myGenerator = new QuickClassStuffer.ClassStuffer();

            myGenerator.StuffProperty <ExampleClass>(z => z.AStringFromFile, myObject);
            var observe2 = myObject.AStringFromFile;

            Assert.IsTrue(observe1 != observe2);
        }
コード例 #2
0
        public void CanPopulateSpecificFieldInExistingArray()
        {
            var results = new List <ExampleClass>();

            results.Add(new ExampleClass());
            results.Add(new ExampleClass());
            results.Add(new ExampleClass());
            results.Add(new ExampleClass());

            var myGenerator = new QuickClassStuffer.ClassStuffer();

            var stringSnapshot = results.Select(r => r.AStringFromFile).ToList();

            myGenerator.StuffProperty <ExampleClass>(z => z.AStringFromFile, results);

            stringSnapshot.AddRange(results.Select(r => r.AStringFromFile).ToList());

            Assert.IsTrue(stringSnapshot.Count() == 8);
            var resultSnapshot = stringSnapshot.Where(s => s != null);

            Assert.IsTrue(resultSnapshot.Count() == 4);
        }