public void Constructor_With2Images_ConcatImageIds() { // Given BaseAd ad = new Ad(); ad.AddImage(new AdImage() { Id = Guid.Parse("e9da8b1e-aa77-401b-84e0-a1290130b7b7") }); ad.AddImage(new AdImage() { Id = Guid.Parse("e9da8b1e-aa77-401b-84e0-a1290130b7b9") }); // When AdCreateModel actual = new AdCreateModel(ad); // Then Assert.AreEqual("e9da8b1e-aa77-401b-84e0-a1290130b7b7;e9da8b1e-aa77-401b-84e0-a1290130b7b9;", actual.ImageIds); }
public void InsertInMemoryData() { //------------------------------------------- // LOCATION REFERENCE TABLES //------------------------------------------- using (ITransaction transaction = _sessionFactory.GetCurrentSession().BeginTransaction()) { //------------------------------------------- // USER TABLE //------------------------------------------- //Create User 1 User user = new User(); user.Email = "*****@*****.**"; user.Password = "******"; user.Firstname = "Bruno"; user.Lastname = "Secret"; _sessionFactory.GetCurrentSession().Save(user); //Create User 2 User user2 = new User(); user2.Email = "*****@*****.**"; user2.Password = "******"; user2.Firstname = "Nicolas"; user2.Lastname = "Secret"; _sessionFactory.GetCurrentSession().Save(user2); //------------------------------------------- // IMAGES //------------------------------------------- AdImage img1 = new AdImage(); img1.Id = Guid.Parse("acd04523-f2fc-47b5-a7af-50b33c49694f"); img1.IsPrimary = true; img1.UploadedDate = new DateTime(); log.Info(_sessionFactory.GetCurrentSession().Save(img1)); AdImage img2 = new AdImage(); img2.Id = Guid.Parse("262dcc07-8c90-4af8-b99c-12e48afac89f"); img2.IsPrimary = true; img2.UploadedDate = new DateTime(); log.Info(_sessionFactory.GetCurrentSession().Save(img2)); //------------------------------------------- // AD TABLE //------------------------------------------- var normalCategories = _sessionFactory.GetCurrentSession().Query <Category>() .Where(x => x.Type == AdTypeEnum.Ad) .ToList(); int nbCategories = normalCategories.Count; int nbCities = _repository.CountAll <City>(); for (int i = 1; i < 31; i++) { BaseAd ad = null; ad = new Ad(); normalCategories[Faker.RandomNumber.Next(0, nbCategories - 1)].AddAd(ad); Faker.Lorem.Words(3).ForEach(s => ad.Title += " " + s); ad.Body = Faker.Lorem.Paragraph(); ad.IsOffer = true; ad.CreationDate = DateTime.Now .AddDays(Faker.RandomNumber.Next(-7, 0)) .AddHours(Faker.RandomNumber.Next(1, 23)) .AddMinutes(Faker.RandomNumber.Next(1, 59)) .AddSeconds(Faker.RandomNumber.Next(1, 59)); ad.Price = Faker.RandomNumber.Next(1, 300000); ad.PhoneNumber = String.Format("{0}.{1}.{2}", Faker.RandomNumber.Next(20, 99), Faker.RandomNumber.Next(20, 99), Faker.RandomNumber.Next(20, 99)); if (i == 1) { ad.AddImage(img1); } if (i == 2) { ad.AddImage(img2); } ad.CreatedBy = user; ad.IsActivated = false; ad.ActivationToken = "activateme"; _repository.Get <City>(Faker.RandomNumber.Next(1, nbCities)).AddAd(ad); _sessionFactory.GetCurrentSession().Save(ad); } _sessionFactory.GetCurrentSession().Update(img1); _sessionFactory.GetCurrentSession().Update(img2); //------------------------------------------- // REFERENCE TABLES //------------------------------------------- transaction.Commit(); } }