public void SupportsMoqArgumentMatches() { var connectionFactory = new Mock <IDbConnectionFactory>(); var connection = new MockDbConnection(); var repository = new SampleRepository(connectionFactory.Object); connectionFactory .Setup(f => f.OpenConnection()) .Returns(connection); connection.Setup(c => c.Query <string>(It.Is <string>(sql => sql.Contains("[Cars]")), It.IsAny <object>(), It.IsAny <IDbTransaction>(), true, null, null)) .Returns(new[] { "Astra" }); repository.GetModels("Vauxhall"); connection.Verify(c => c.Query <string>(It.IsAny <string>(), It.Is <object>(p => p.Prop <string>("make") == "Vauxhall"), It.IsAny <IDbTransaction>(), true, null, null)); }
public void SupportsMoqArgumentMatches() { var connectionFactory = new Mock <IDbConnectionFactory>(); var connection = new MockDbConnection(); var repository = new SampleRepository(connectionFactory.Object); var vauxhall = new Car { Registration = "ABC123", Make = "Vauxhall", Model = "Astra" }; connectionFactory .Setup(f => f.OpenConnection()) .Returns(connection); connection.Setup(c => c.Query <Car>(It.Is <string>(sql => sql.Contains("[Cars]")), It.IsAny <object>())) .Returns(new[] { vauxhall }); repository.GetModels("Vauxhall"); connection.Verify(c => c.Query <Car>(It.IsAny <string>(), It.Is <object>(p => p.Prop <string>("make") == "Vauxhall"))); }