Esempio n. 1
0
        public async Task Create_WithValidData_ShouldIncludeIntoDatabase()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var context             = new ApplicationDbContext(options);
            var eventsService       = new EventsService(context);
            EventServiceModel model = new EventServiceModel
            {
                Name           = "Test Place 1",
                Place          = "somewhere",
                StartDate      = DateTime.UtcNow,
                EndDate        = DateTime.UtcNow,
                TotalTickets   = 5,
                PricePerTicket = 4.8m
            };

            await eventsService.CreateAsync(model);

            // Act
            var count = (eventsService.GetAll()).Count();

            // Assert
            Assert.Equal(1, count);
        }
Esempio n. 2
0
        public ActionResult Remove(int Id)
        {
            this._provider = new EventsService(DomainSession.GetAlarmConfigForContextSession(this.HttpContext));
            AlarmSystemEventsModel model = new AlarmSystemEventsModel(_provider.GetAll());
            bool remRes = _provider.RemoveById(Id);

            model.Result = StatusResponseGenerator.GetStatusResponseResultForReturnParam(remRes);
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult Search(string key)
        {
            this._provider = new EventsService(DomainSession.GetAlarmConfigForContextSession(this.HttpContext));
            AlarmSystemEventsModel model = new AlarmSystemEventsModel(_provider.GetAll());

            if (!String.IsNullOrEmpty(key))
            {
                model.Events = model.Events.Where(d => d.Type.ToString().Contains(key)).ToList();
            }
            return(View(model));
        }
Esempio n. 4
0
        public async Task GetAllShouldReturnAllEvents()
        {
            await this.PopulateEvents();

            var service = new EventsService(
                this.eventsRepository,
                this.postsService,
                this.postRepository);

            List <TestEventViewModel> models = service.GetAll <TestEventViewModel>().ToList();

            Assert.Equal(3, models.Count);
        }
Esempio n. 5
0
        public async Task GetAllShouldReturnCorrectCount()
        {
            var service = new EventsService(this._dbContext, this._mapper, this._moviesService, this._peopleService);
            await service.CreateEvent(new CreateEventViewModel());

            await service.CreateEvent(new CreateEventViewModel());

            var allEvents = await service.GetAll();

            var count = allEvents.Count();

            Assert.Equal(2, count);
        }
        public async Task GetAll_WithTickets_ShouldReturnCorrectValue()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <EventuresDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var context       = new EventuresDbContext(options);
            var eventsService = new EventsService(context);

            object[] models =
            {
                new EventuresEvent
                {
                    Name           = "Test Event 1",
                    Place          = "Test Place 1",
                    StartDate      = DateTime.UtcNow,
                    EndDate        = DateTime.UtcNow,
                    TotalTickets   = 2,
                    PricePerTicket = 2
                },
                new EventuresEvent
                {
                    Name           = "Test Event 2",
                    Place          = "Test Place 2",
                    StartDate      = DateTime.UtcNow,
                    EndDate        = DateTime.UtcNow,
                    TotalTickets   = 3,
                    PricePerTicket = 3
                }
            };
            await context.AddRangeAsync(models);

            await context.SaveChangesAsync();

            // Act
            var count = (await eventsService.GetAll()).Count();

            // Assert
            Assert.Equal(2, count);
        }
Esempio n. 7
0
        public async Task All_WithExistingData_ShouldReturnAllOfExistingDataWithTickets()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var context       = new ApplicationDbContext(options);
            var eventsService = new EventsService(context);

            object[] models =
            {
                new Event
                {
                    Name           = "Test Event 1",
                    Place          = "Test Place 1",
                    StartDate      = DateTime.UtcNow,
                    EndDate        = DateTime.UtcNow,
                    TotalTickets   = 2,
                    PricePerTicket = 2
                },
                new Event
                {
                    Name           = "Test Event 2",
                    Place          = "Test Place 2",
                    StartDate      = DateTime.UtcNow,
                    EndDate        = DateTime.UtcNow,
                    TotalTickets   = 0,
                    PricePerTicket = 3
                }
            };
            await context.AddRangeAsync(models);

            await context.SaveChangesAsync();

            // Act
            var count = (eventsService.GetAll()).Count();

            // Assert
            Assert.Equal(1, count);
        }
 public virtual JsonResult Read([DataSourceRequest] DataSourceRequest request)
 {
     return(Json(eventsService.GetAll().ToDataSourceResult(request)));
 }