Ejemplo n.º 1
0
        public void InvokeMemberContainsName()
        {
            dynamic clay   = new Clay(new TestBehavior());
            var     result = clay.Hello();

            Assert.That(result, Does.Contain("[name:Hello]"));
            Assert.That(result, Does.Contain("[count:0]"));
        }
Ejemplo n.º 2
0
        public void ArrayCombinesWithOtherBehaviors()
        {
            dynamic combo = new Clay(
                new InterfaceProxyBehavior(),
                new PropBehavior(),
                new ArrayBehavior(),
                new NilResultBehavior());

            Assert.That(combo.Count, Is.EqualTo(0));

            combo.Hello = "world";
            Assert.That(combo.Hello, Is.EqualTo("world"));
            Assert.That(combo.Hello(), Is.EqualTo("world"));
            Assert.That(combo["Hello"], Is.EqualTo("world"));

            Assert.That(combo.Count, Is.EqualTo(0));

            combo.Add("alpha", "beta");
            Assert.That(combo.Count, Is.EqualTo(2));
            Assert.That(combo[0], Is.EqualTo("alpha"));
            Assert.That(combo[1], Is.EqualTo("beta"));

            var c2 = (ICombo)combo;

            Assert.That(c2.Hello, Is.EqualTo("world"));
            Assert.That(c2.Length, Is.EqualTo(2));
            Assert.That(c2.Count, Is.EqualTo(2));
            Assert.That(c2[0], Is.EqualTo("alpha"));
            Assert.That(c2[1], Is.EqualTo("beta"));
            Assert.That(c2.Again, Is.Null);

            Assert.That(c2.Extra.Title, Is.Null);
            Assert.That(c2.Extra.Description, Is.Null);

            Assert.That(c2.Aggregate(">", (a, b) => a + "(" + b + ")"), Is.EqualTo(">(alpha)(beta)"));
        }