예제 #1
0
        public void DifferentInstanceCreatedEachCall()
        {
            dynamic factory = new Clay(new ClayFactoryBehavior());
            object  alpha1  = factory.Alpha();
            object  alpha2  = factory.Alpha();

            Assert.That(alpha1, Is.Not.SameAs(alpha2));
        }
예제 #2
0
        public void FactoryMethodCopiesPropertiesOfOptionalArgument()
        {
            dynamic factory = new Clay(new ClayFactoryBehavior());
            var     alpha   = factory.Alpha(new { One = 1, Two = "dos" });

            Assert.That(alpha.One, Is.EqualTo(1));
            Assert.That(alpha.Two, Is.EqualTo("dos"));
        }
예제 #3
0
        public void InvokingMethodsCreateDynamicObjectWithBehaviors()
        {
            dynamic factory = new Clay(new ClayFactoryBehavior());
            object  alpha   = factory.Alpha();

            Assert.That(alpha, Is.Not.Null);
            Assert.That(alpha, Is.AssignableTo <IDynamicMetaObjectProvider>());
            Assert.That(alpha, Is.AssignableTo <IClayBehaviorProvider>());
        }
예제 #4
0
        public void FactoryMethodUsesNamedParameters()
        {
            dynamic factory = new Clay(new ClayFactoryBehavior());

            var alpha = factory.Alpha(new { Red = "#f00" }, One: 1, Two: "dos");

            Assert.That(alpha.One, Is.EqualTo(1));
            Assert.That(alpha.Two, Is.EqualTo("dos"));
            Assert.That(alpha.Red, Is.EqualTo("#f00"));
        }