public void FindMaxValue_DataPresent_ReturnsEntityWithMaximumValue() { // Arrange var count = 10; string filePath = null; try { var approvalStatus = 0; var articles = new List <Article>(); for (var i = 0; i < count; i++) { articles.Add(new Article { ApprovalStatus = approvalStatus, ApprovedBy = "Ryan", DateApproved = DateTime.Now, DateTime = DateTime.Now.AddDays(-1), Id = Guid.NewGuid(), Rating = 5, RelatesToId = Guid.NewGuid().ToString(), RelatesToType = "Test", ThreadId = Guid.NewGuid(), UserId = Guid.NewGuid().ToString(), WebsiteId = Guid.NewGuid() }); approvalStatus += 100; } var serialisedArticles = JsonConvert.SerializeObject(articles); var serialisedArticleBytes = System.Text.Encoding.Unicode.GetBytes(serialisedArticles); filePath = System.IO.Path.Combine(Utilities.IO.UncPath.GetApplicationDirectory(), "[Foundation].[Article].json"); System.IO.File.WriteAllBytes(filePath, serialisedArticleBytes); var articleRepository = new ArticleRepository(); var sourceObject = articles.OrderByDescending(a => a.ApprovalStatus).First(); // Act var result = articleRepository.FindMaxValue <int>("ApprovalStatus"); // Assert Assert.AreEqual(sourceObject.ApprovalStatus, result); } finally { if (!string.IsNullOrWhiteSpace(filePath)) { Utilities.IO.File.Delete(filePath); } } }