public void DifferentInstanceCreatedEachCall() { dynamic factory = new Clay(new ClayFactoryBehavior()); object alpha1 = factory.Alpha(); object alpha2 = factory.Alpha(); Assert.That(alpha1, Is.Not.SameAs(alpha2)); }
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")); }
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>()); }
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")); }