public void GetQueryParametersAlwaysReturnsTheSameInstance() { string query = "select * from s where s.Account = @account and s.Balance > @balance"; QueryDefinition queryDefinition = new QueryDefinition(query) .WithParameter("@account", "12345") .WithParameter("@balance", 42); IReadOnlyList <(string Name, object Value)> parameters1 = queryDefinition.GetQueryParameters(); IReadOnlyList <(string Name, object Value)> parameters2 = queryDefinition.GetQueryParameters(); Assert.AreSame(parameters1, parameters2); }
public void GetQueryParametersReturnsListOfTuples() { string query = "select * from s where s.Account = @account and s.Balance > @balance"; QueryDefinition queryDefinition = new QueryDefinition(query) .WithParameter("@account", "12345") .WithParameter("@balance", 42); IReadOnlyList <(string Name, object Value)> parameters = queryDefinition.GetQueryParameters(); Assert.AreEqual(2, parameters.Count); Assert.AreEqual("@account", parameters[0].Name); Assert.AreEqual("12345", parameters[0].Value); Assert.AreEqual("@balance", parameters[1].Name); Assert.AreEqual(42, parameters[1].Value); }
public void GetQueryParametersGetEnumeratorEnumeratesParameters() { string query = "select * from s where s.Account = @account and s.Balance > @balance"; QueryDefinition queryDefinition = new QueryDefinition(query) .WithParameter("@account", "12345") .WithParameter("@balance", 42); IReadOnlyList <(string Name, object Value)> parameters = queryDefinition.GetQueryParameters(); IEnumerator <(string Name, object Value)> enumerator = parameters.GetEnumerator(); Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual("@account", enumerator.Current.Name); Assert.AreEqual("12345", enumerator.Current.Value); Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual("@balance", enumerator.Current.Name); Assert.AreEqual(42, enumerator.Current.Value); Assert.IsFalse(enumerator.MoveNext()); }