public void MapBand() { //Arrange var id = Guid.NewGuid(); var entity = new BandEntity { Id = id, Country = "Country", Events = new List <EventEntity>(), Genre = "Genre", ImagePath = "ImagePath", LongDescription = "Long Description", Name = "Name", ShortDescription = "Short Description" }; var model = new BandDetailModel { Id = id, Country = "Country", Events = new List <EventDetailModel>(), Genre = "Genre", ImagePath = "ImagePath", LongDescription = "Long Description", Name = "Name", ShortDescription = "Short Description" }; //Act var entityAdapted = model.Adapt <BandEntity>(); entityAdapted.Events = model.Events.Adapt <List <EventEntity> >(); var modelAdapted = entity.Adapt <BandDetailModel>(); modelAdapted.Events = entity.Events.Adapt <List <EventDetailModel> >(); //Assert Assert.Equal(entity, entityAdapted, BandEntity.BandEntityComparer); Assert.Equal(model, modelAdapted, BandDetailModel.BandDetailModelComparer); }
public IList <BandDetailModel> SeedDataBands() { using var dbContext = DbContextFactory.CreateDbContext(); var bandList = new List <BandDetailModel>(); for (var i = 0; i < 50; i++) { var band = new BandEntity { Country = $"Czech{i}", Genre = $"Rock{i}", Name = $"Name{i}", ImagePath = $"C:/Users/testUser/Images/image{i}.jpg", LongDescription = $"Long description of band{i}", ShortDescription = $"Short description of band{i}" }; dbContext.Bands.Add(band); bandList.Add(band.Adapt <BandDetailModel>()); } dbContext.SaveChanges(); return(bandList); }