public void GetQueryParametersByQueryIdMethodTest() { // Arrange TestDbSet <Parameter> parametersDbSet = new TestDbSet <Parameter>() { new Parameter() { ParameterId = 0, ParameterName = "@test", ParameterRuName = "test", ParameterType = "text", ParameterCreatedDate = DateTime.Now }, new Parameter() { ParameterId = 1, ParameterName = "@another_one", ParameterRuName = "another_one", ParameterType = "number", ParameterCreatedDate = DateTime.Now }, new Parameter() { ParameterId = 2, ParameterName = "@param", ParameterRuName = "param", ParameterType = "phone", ParameterCreatedDate = DateTime.Now } }; TestDbSet <SqlQuery> queriesDbSet = new TestDbSet <SqlQuery>() { new SqlQuery() { SqlQueryId = 0, SqlQueryName = "First query", SqlQueryContent = "Select * from test", SqlQueryCreatedDate = DateTime.Now } }; TestDbSet <SqlQueryParameter> queryParametersDbSet = new TestDbSet <SqlQueryParameter>() { new SqlQueryParameter() { SqlQueryParameterId = 0, SqlQueryId = 0, ParameterId = 0 }, new SqlQueryParameter() { SqlQueryParameterId = 1, SqlQueryId = 0, ParameterId = 1 } }; var mock = new Mock <IContext>(); mock .Setup(x => x.Parameters) .Returns(parametersDbSet); mock .Setup(x => x.SqlQueries) .Returns(queriesDbSet); mock .Setup(x => x.SqlQueryParameters) .Returns(queryParametersDbSet); ParameterRepository repository = new ParameterRepository(mock.Object); // Act IEnumerable <Parameter> parameters = repository.GetQueryParametersByQueryId(0); // Assert Assert.AreEqual(2, parameters.Count()); Assert.IsTrue( queryParametersDbSet .Select(i => i.ParameterId) .Contains(parameters.First().ParameterId) ); Assert.IsTrue( queryParametersDbSet .Select(i => i.ParameterId) .Contains(parameters.Last().ParameterId) ); }