コード例 #1
0
        public void Test_Add_Multiple_Bindings_To_Collection_Throws_ArgumentNullException()
        {
            IBindingCollection collection = new BindingCollection();

            Assert.Throws <ArgumentNullException>(() =>
            {
                collection.AddRange(null);
            });
        }
コード例 #2
0
        public static async Task Fill <T>(this BindingCollection <T> self, IEnumerable <T> items, int itemsPerIteration = 100)
        {
            self.AllItems = items;

            self.Clear();

            if (itemsPerIteration == -1)
            {
                self.AddRange(items);
            }
            else
            {
                var groupCount = items.Count() / itemsPerIteration;
                for (int index = 0; index < groupCount; index++)
                {
                    var part = items.Skip(index * itemsPerIteration).Take(itemsPerIteration);
                    self.AddRange(part);
                    await Task.Delay(1).ConfigureAwait(true);
                }
            }
        }
コード例 #3
0
        public void Test_Add_Multiple_Bindings_To_Collection()
        {
            IBinding <ISample> binding = from b in Bind <ISample>()
                                         select new Sample();
            IBinding <ISample>    otherSampleBinding = Bind <ISample>().Select(b => new Sample(new object()));
            IBinding <IHasSample> otherBinding       = from b in Bind <IHasSample>()
                                                       select new HasSample(Dependency(binding));

            IBindingCollection collection = new BindingCollection();

            collection.AddRange(new IBinding[] { binding, otherBinding, otherSampleBinding });

            Assert.Equal(3, collection.BindingCount);
        }