public void GetLastResultByType_Should_Return_Last_Valid_Statistics_For_Type() { RunTest(() => { var statisticOne = new Statistic { Id = Guid.NewGuid(), Type = StatisticType.Movie, CalculationDateTime = DateTime.Now, JsonResult = "", IsValid = false, CollectionIds = new string[0] }; var statisticTwo = new Statistic { Id = Guid.NewGuid(), Type = StatisticType.Movie, CalculationDateTime = DateTime.Now, JsonResult = "", IsValid = true, CollectionIds = new string[0] }; var statisticThree = new Statistic { Id = Guid.NewGuid(), Type = StatisticType.Show, CalculationDateTime = DateTime.Now, JsonResult = "", IsValid = true, CollectionIds = new string[0] }; var statisticFour = new Statistic { Id = Guid.NewGuid(), Type = StatisticType.Movie, CalculationDateTime = DateTime.Now, JsonResult = "", IsValid = true, CollectionIds = new[] { "1" } }; using (var database = _context.LiteDatabase) { var collection = database.GetCollection <Statistic>(); collection.InsertBulk(new[] { statisticOne, statisticTwo, statisticThree, statisticFour }); } var statistic = _statisticsRepository.GetLastResultByType(StatisticType.Movie, new string[0]); statistic.Should().NotBeNull(); statistic.Id.Should().Be(statisticTwo.Id); statistic.CalculationDateTime.Should().BeCloseTo(statisticTwo.CalculationDateTime, 10); statistic.CollectionIds.Should().BeEquivalentTo(statisticTwo.CollectionIds); statistic.IsValid.Should().BeTrue(); statistic.Type.Should().Be(statisticTwo.Type); }); }