public void ShouldAllowDynamicAsParameter() { // Arrange var value = 5; var something = new DoSomethingUseful(); // Act var result = something.Execute(value); // Assert result.Should().Be(value); }
public void ShouldAllowReAssignmentOfComplexTypes() { // Arrange dynamic d = new DoSomethingUseful(); // Pre-Assert Assert.AreEqual(typeof(DoSomethingUseful), d.GetType()); // Act d = new TheThing(); // Assert Assert.AreEqual(typeof(TheThing), d.GetType()); }
public void ShouldThrowRuntimeExceptionWhenCallingMethodThatDoesNotExist() { // Arrange dynamic something = new DoSomethingUseful(); // Act try { something.SomeMethodThatDoesNotExist(); } catch (Exception e) { // Assert e.Message.Should() .Be("'Dynamic.DoSomethingUseful' does not contain a definition for 'SomeMethodThatDoesNotExist'"); } }