public async Task CreateAsyncWithInCorrectDataShouldThrowArgumentException()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext        = new ApplicationDbContext(options);
            var cloudinary       = new Mock <ICloudinaryService>();
            var venuesRepository = new EfDeletableEntityRepository <Venue>(dbContext);
            var venuesService    = new VenuesService(venuesRepository, cloudinary.Object);
            var photo            = new Mock <IFormFile>();

            await venuesRepository.AddAsync(new Venue
            {
                Name     = "Port Varna",
                ImgUrl   = "https://res.cloudinary.com/nikolacgeorgiev/image/upload/v1587377702/venues_photos/Port_Varna_t44ryy.jpg",
                Country  = "Bulgaria",
                City     = "Varna",
                Address  = "Sq. Slaveykov 1",
                Capacity = 30000,
            });

            await venuesRepository.SaveChangesAsync();

            await Assert.ThrowsAsync <ArgumentException>(async() =>
            {
                await venuesService.CreateAsync("Port Varna", photo.Object, "Bulgaria", "Sofia", "Sq. Slaveykov 1", 100000);
            });
        }
Ejemplo n.º 2
0
        public void CanMakeCityAndAllItsVenuesNotAvaliable_CitiesService()
        {
            using (var context = new TicketsResellingContext(ContextOptions))
            {
                var citiesService = new CitiesService(context);
                var venueService  = new VenuesService(context);

                citiesService.MakeCityAndAllItsVenuesNotAvaliable(2);

                var city   = citiesService.GetCityById(2).Result;
                var venues = venueService.GetVenuesByStatuses(VenueStatuses.NotAvaliable).Result.ToList();

                city.Status.Should().Be(CityStatuses.NotAvaliable);
                venues.Count.Should().Be(4);
            }
        }
        public async Task CreateAsyncWithCorrectDataShouldReturnCorrectResult()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext        = new ApplicationDbContext(options);
            var cloudinary       = new Mock <ICloudinaryService>();
            var venuesRepository = new EfDeletableEntityRepository <Venue>(dbContext);
            var venuesService    = new VenuesService(venuesRepository, cloudinary.Object);
            var photo            = new Mock <IFormFile>();

            var actual = await venuesService
                         .CreateAsync("Port Varna", photo.Object, "Bulgaria", "Varna", "Sq. Slaveykov 1", 30000);

            var expected = 1;

            Assert.Equal(expected, actual);
        }
        public async Task EditAsyncWithCorrectDataShouldReturnCorrectResult()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext        = new ApplicationDbContext(options);
            var cloudinary       = new Mock <ICloudinaryService>();
            var venuesRepository = new EfDeletableEntityRepository <Venue>(dbContext);
            var venuesService    = new VenuesService(venuesRepository, cloudinary.Object);
            var photo            = new Mock <IFormFile>();

            var id = await venuesService.CreateAsync("Rowing Canal", photo.Object, "Bulgaria", "Plovdiv", "Yasna Polyana", 70000);

            var venue = new VenueEditInputModel
            {
                Name     = "Port Varna",
                ImgUrl   = "https://res.cloudinary.com/nikolacgeorgiev/image/upload/v1587377702/venues_photos/Port_Varna_t44ryy.jpg",
                Country  = "Bulgaria",
                City     = "Varna",
                Address  = "Sq. Slaveykov 1",
                Capacity = 30000,
            };

            Assert.True(await venuesService.EditAsync(id, venue));
        }