public void FilteryByPublished_articles_returns_published_articles_when_filter_by_published_false() { var query = new EnumerableQuery <Article>(_articles).FilteryByPublished(false); query.Count().Should().Be(1); query.Each(x => x.IsPublished.Should().Be.True()); }
public void Index_returns_list_of_correct_Trips() { TripController controller = new TripController(repository, provider); ViewResult result = controller.Index() as ViewResult; Assert.IsNotNull(result); EnumerableQuery <Trip> model = (EnumerableQuery <Trip>)result.ViewData.Model; Assert.IsNotNull(model); Assert.AreEqual(1, model.Count()); Assert.IsTrue(model.Contains(userTrip)); }
public IEnumerable <Band> Search(BandSearchInformation bandSearchInformation, out int totalMatches) { using (var context = new MusicArchiveContext()) { IQueryable <Band> matches = new EnumerableQuery <Band>(context.Bands); if (!string.IsNullOrWhiteSpace(bandSearchInformation.BandName)) { matches = matches.Where(b => b.Name.Contains(bandSearchInformation.BandName)); } if (!string.IsNullOrWhiteSpace(bandSearchInformation.CountryOfOrigin)) { matches = matches.Where(band1 => band1.CountryOfOrgin == bandSearchInformation.CountryOfOrigin); } if (!string.IsNullOrWhiteSpace(bandSearchInformation.Genre)) { matches = matches.Where(band1 => band1.Genre == bandSearchInformation.Genre); } if (!string.IsNullOrWhiteSpace(bandSearchInformation.Label)) { //matches = matches.Where(band1 => band1.CurrentLabel == bandSearchInformation.Label); } if (!string.IsNullOrWhiteSpace(bandSearchInformation.YearOfFormation)) { matches = matches.Where(band1 => band1.FormedIn == bandSearchInformation.YearOfFormation); //TODO make this an actual date... } if (!string.IsNullOrWhiteSpace(bandSearchInformation.LyricalThemes)) { matches = matches.Where(band1 => band1.LyricalThemes == bandSearchInformation.LyricalThemes); } totalMatches = matches.Count(); return(matches.OrderBy(band => band.Name).Skip(bandSearchInformation.StartingRecordNumber).Take(bandSearchInformation.PageSize).ToList()); } }
public static void Demo() { Console.WriteLine("AutoMapping ====================="); var mapperConfiguration = new MapperConfiguration(cfg => cfg.AddProfile<MyProfile>()); mapperConfiguration.AssertConfigurationIsValid<MyProfile>(); var mapper = mapperConfiguration.CreateMapper(); Trace.Assert(EnumB.V1 == mapper.Map<EnumB>(EnumA.V1)); Trace.Assert(EnumA.V1 == mapper.Map<EnumA>(EnumB.V1)); var deep = new DeepAggregate(); Trace.Assert(deep.Address != null); // largely guaranteed from nullable reference types deep.Address!.City = "La Paz"; deep.Address.Province = "Bolivia"; deep.FlaggedAt = DateTime.UtcNow; var flatAuto = mapper.Map<FlatAggregate>(deep); Trace.Assert(flatAuto.AddressCity == "La Paz"); Trace.Assert(flatAuto.AddressRegion == "Bolivia"); Trace.Assert(flatAuto.IsFlagged); var deepAuto = mapper.Map<DeepAggregate>(flatAuto); Trace.Assert(deepAuto.Address.City == deep.Address.City); Trace.Assert(deepAuto.Address.Province == deep.Address.Province); Trace.Assert(deepAuto.FlaggedAt == null); //<<<< one way only var deeps = new EnumerableQuery<DeepAggregate>(new[] {deep, deepAuto}); Trace.Assert(1 == deeps.Count(d => d.FlaggedAt != null)); var projectedFlats = deeps.ProjectTo<FlatAggregate>(mapper.ConfigurationProvider, a => a.IsFlagged); Trace.Assert(2 == projectedFlats.Count(f => f.AddressRegion == "Bolivia")); Trace.Assert(0 == projectedFlats.Count(f => f.AddressRegion == "Bolognese")); Trace.Assert(1 == projectedFlats.Count(f => f.IsFlagged)); Trace.Assert(1 == projectedFlats.Count(f => !f.IsFlagged)); }
public void FilteryByPublished_articles_returns_all_articles_when_filter_not_set() { var query = new EnumerableQuery <Article>(_articles).FilteryByPublished(null); query.Count().Should().Be(2); }
public void Then_each_usage_is_converted() { // Assert Assert.That(_result.Count(), Is.EqualTo(_usagesInRepository.Count() + 1), "All usages should be reported, plus the header row"); }