public void FindParametersByNameOrderedByCreatedDescMethodTest() { // Arrange TestDbSet <Parameter> parametersDbSet = new TestDbSet <Parameter>() { new Parameter() { ParameterId = 0, ParameterName = "first parameter name", ParameterRuName = "nevermind", ParameterType = "text", ParameterCreatedDate = DateTime.Today }, new Parameter() { ParameterId = 1, ParameterName = "second parameter", ParameterRuName = "same", ParameterType = "phone", ParameterCreatedDate = DateTime.Today.AddDays(-1) }, new Parameter() { ParameterId = 2, ParameterName = "third parameter name", ParameterRuName = "unclear", ParameterType = "number", ParameterCreatedDate = DateTime.Today.AddDays(-2) } }; var mock = new Mock <IContext>(); mock .Setup(x => x.Parameters) .Returns(parametersDbSet); ParameterRepository repository = new ParameterRepository(mock.Object); // Act IEnumerable <Parameter> parameters = repository.FindParametersByNameOrderedByCreatedDesc("name"); int[] expectedParameterIds = new int[] { 0, 2 }; // Assert Assert.AreEqual(2, parameters.Count()); Assert.IsFalse(expectedParameterIds.Contains(1)); Assert.IsTrue(parameters.First().ParameterCreatedDate > parameters.Last().ParameterCreatedDate); foreach (Parameter param in parameters) { Assert.IsTrue(param.ParameterName.Contains("name")); Assert.IsTrue(expectedParameterIds.Contains(param.ParameterId)); } }