public void CanReplaceAMethodMapping() { // Arrange IInterfaceMap target = CreateIInterfaceMap(); IMethodMapping mapping = CreateIMethodMapping(); mapping.Name = "test"; mapping.GenericArgumentTypes = new Type[] { typeof(string), typeof(object) }; mapping.ArgumentTypes = new Type[] { typeof(bool) }; mapping.Subject = (arg, args) => { Console.Out.WriteLine("Subject called"); return(true); }; IMethodMapping replacement = CreateIMethodMapping(); replacement.Name = "test"; replacement.GenericArgumentTypes = new Type[] { typeof(string), typeof(object) }; replacement.ArgumentTypes = new Type[] { typeof(bool) }; replacement.Subject = (arg, args) => { Console.Out.WriteLine("Subject replacement called"); return(true); }; // Act target.Add(mapping, false); target.Add(replacement, true); // Assert Verify.That(target.AsEnumerable()).DoesContain(replacement, "Should contain the replacement") .Now(); Verify.That(target.AsEnumerable()).DoesNotContain(mapping, "Should not contain the original mapping") .Now(); }
public void CanRemoveContained() { // Arrange IInterfaceMap target = CreateIInterfaceMap(); IMethodMapping mapping = CreateIMethodMapping(); mapping.Name = "test"; mapping.GenericArgumentTypes = Type.EmptyTypes; mapping.ArgumentTypes = Type.EmptyTypes; bool actual; target.Add(mapping); // Act actual = target.Remove(mapping); // Assert Verify.That(actual).IsTrue() .Now(); }
public void CanAddWithReplaceSetToFalse() { // Arrange IInterfaceMap target = CreateIInterfaceMap(); IMethodMapping mapping = CreateIMethodMapping(); mapping.Name = "test"; mapping.GenericArgumentTypes = new Type[] { typeof(string), typeof(object) }; mapping.ArgumentTypes = new Type[] { typeof(bool) }; mapping.Subject = (arg, args) => { Console.Out.WriteLine("Subject called"); return(true); }; bool replace = false; // Act target.Add(mapping, replace); // Assert Verify.That(target.AsEnumerable()).DoesContain(mapping) .Now(); }