Пример #1
0
    public Form1()
    {
        InitializeComponent();
        List <Foo> foos = new List <Foo>();
        Foo        a    = new Foo("letters");

        a.Add(new Bar("a", "aaa"));
        a.Add(new Bar("b", "bbb"));
        foos.Add(a);
        Foo b = new Foo("digits");

        b.Add(new Bar("1", "111"));
        b.Add(new Bar("2", "222"));
        b.Add(new Bar("3", "333"));
        foos.Add(b);
        //Simple Related Object List Binding
        //http://blogs.msdn.com/bethmassi/archive/2007/04/21/simple-related-object-list-binding.aspx
        BindingSource comboBoxBindingSource = new BindingSource();
        BindingSource listBoxBindingSource  = new BindingSource();

        comboBoxBindingSource.DataSource = foos;
        listBoxBindingSource.DataSource  = comboBoxBindingSource;
        listBoxBindingSource.DataMember  = "Items";
        comboBox1.DataSource             = comboBoxBindingSource;
        comboBox1.DisplayMember          = "FooName";
        listBox1.DataSource    = listBoxBindingSource;
        listBox1.DisplayMember = "BarName";
        textBox1.DataBindings.Add("Text", listBoxBindingSource, "BarDesc");
    }
Пример #2
0
            public void UnseqequalityComparerViaBuilder3()
            {
                SCG.IEqualityComparer <IFoo <int> > h = C5.EqualityComparer <IFoo <int> > .Default;
                IFoo <int> s = new Foo <int>();

                s.Add(1); s.Add(2); s.Add(3);
                Assert.AreEqual(CHC.unsequencedhashcode(1, 2, 3), h.GetHashCode(s));
            }
Пример #3
0
    static void Main(string[] args)
    {
        Foo A = new Foo();
        Foo B = new Foo();
        Foo C = new Foo();

        Console.WriteLine(C.Add(B));
        Console.WriteLine(B.Add(A));
        Console.WriteLine(A.Add(C));
        Console.WriteLine(C.Add(A));
    }
Пример #4
0
        public async Task Can_update_doc()
        {
            const string id  = "id-1";
            var          doc = new Foo(id);

            doc.Add(2);
            await _repository.Save(doc);

            doc = await _repository.Load(id);

            doc.Add(3);
            await _repository.Save(doc);

            doc = await _repository.Load(id);

            doc.Balance.ShouldBe(5);
        }
Пример #5
0
        public void ItemChangedObservation()
        {
            Foo foo         = new Foo();
            int lastChanged = -1;

            foo.ItemChangedEvent += delegate(object sender, EventArg <ObservedList <int> .ListChangedData <int> > e) {
                lastChanged = e.CurrentValue.Index;
            };

            Assert.AreEqual(-1, lastChanged, "no initial data on changed");
            foo.Add(2);
            foo [0] = 1;

            Assert.AreEqual(1, foo [0], "change was successful");
            Assert.AreEqual(0, lastChanged, "first item changed (added)");

            foo.Add(4);
            foo [1] = 2;
            Assert.AreEqual(1, lastChanged, "second item changed (added)");
        }
Пример #6
0
        public async Task Can_save_and_retrieve_doc()
        {
            const string id  = "id-1";
            var          doc = new Foo(id);

            doc.Add(2);
            int balance = doc.Balance;

            await _repository.Save(doc);

            doc = await _repository.Load(id);

            doc.Balance.ShouldBe(balance);
        }
Пример #7
0
    static void Example()
    {
        Foo f  = new Foo(2);
        Foo f2 = new Foo(3);
        // instead of this, which binds an instance
        OldDelegateStyle oldMul = f.Multiply;
        // You have to use this
        NewFunctionPointer mul = delegate(Foo f, int x) { return(f.Multiply(x)); }
        NewFunctionPointer add = delegate(Foo f, int x) { return(f.Add(x)); }
        // But can now do this
        mul(f, 4);      // = 8

        add(f2, 1);     // = 3
    }
Пример #8
0
        public void ChangedObservation()
        {
            Foo  foo            = new Foo();
            bool changeObserved = false;

            foo.ListChangedEvent += delegate {
                changeObserved = true;
            };

            Assert.AreEqual(changeObserved, false, "changeObserved initially is false");

            foo.Add(1);

            Assert.AreEqual(changeObserved, true, "delegate changes changeObserved");
        }
Пример #9
0
 public void Add_should_add_numbers() => Assert.Equal(2, Foo.Add(1, 1));
Пример #10
0
 public void TwoPlusTwoEqualsFour()
 {
     Assert.AreEqual(Foo.Add(2, 2), 4);
 }
Пример #11
0
 public void NPlusZeroEqualsN()
 {
     Assert.AreEqual(Foo.Add(1, 0), 1);
 }