public void GetAllEventsShouldGetEventsCorrectly()
        {
            var mockList = new List <EventViewModel>
            {
                new EventViewModel
                {
                    StartDateTime = DateTime.ParseExact("2019-08-22 0:00", "yyyy-MM-dd H:mm", CultureInfo.InvariantCulture),
                    EndTime       = DateTime.ParseExact("2019-08-23 3:00", "yyyy-MM-dd H:mm", CultureInfo.InvariantCulture),
                    Name          = "BNI Gathering",
                    Place         = "Elias Canneti Centre",
                    Town          = "Ruse, Bulgaria",
                    Image540X360  = "https://media.licdn.com/dms/image/C5612AQFTYJDHoEc7eQ/article-cover_image-shrink_423_752/0?e=1571875200&v=beta&t=RhecYVQlaqEqXMy0R7j1TW-B9Pca-ez2EOJlSFNIZ_o",
                    Image445X255  = "https://media.licdn.com/dms/image/C5612AQFTYJDHoEc7eQ/article-cover_image-shrink_423_752/0?e=1571875200&v=beta&t=RhecYVQlaqEqXMy0R7j1TW-B9Pca-ez2EOJlSFNIZ_o",
                    VideoLink     = "https://www.youtube.com/watch?v=CbNkack6Bww&feature=youtu.be",
                    About         = "The more KNOWLEDGE you SHARE, the more POINTS you will have. Exchange them for learning NEW SKILLS and SPECIAL AWARDS!",
                }
            };

            var options = new DbContextOptionsBuilder <IntillegioContext>()
                          .UseInMemoryDatabase(databaseName: "Get_All_Events_Db")
                          .Options;
            var dbContext = new IntillegioContext(options);

            var mapper = new Mock <IMapper>();

            mapper.Setup(m => m.Map <IEnumerable <EventViewModel> >(
                             dbContext.Articles))
            .Returns(mockList);

            var eventsCount = 3;

            for (int i = 0; i < eventsCount; i++)
            {
                dbContext.Events.Add(new Event());
            }

            dbContext.SaveChanges();
            var service = new EventsService(dbContext, mapper.Object);

            var allEvents = service.GetAllEvents();

            Assert.NotNull(allEvents);
        }
Esempio n. 2
0
        public ActionResult ListEvents()
        {
            using (ArgaamAnalyticsDataContext aadc = new ArgaamAnalyticsDataContext())
            {
                ViewData["filteredEvents"] = EventsService.GetAllEvents();

                ViewData["companies_SL"] = new SelectList(FintechService.GetStockEntities(1).AsEnumerable().Select((item, index) => new SelectListItem()
                {
                    Value = item.StockEntityID.ToString(), Text = item.NameEn
                }), "Value", "Text");
                var eventCatSLI = EventsService.GetAllParentEventCategories().AsEnumerable().Select((item, index) => new SelectListItem()
                {
                    Value = item.EventCategoryID.ToString(), Text = item.EventCategoryName
                }).ToList();
                eventCatSLI.Insert(0, new SelectListItem()
                {
                    Text = "ANY", Value = "0"
                });
                ViewData["parentEventCategories_SL"] = new SelectList(eventCatSLI, "Value", "Text");
            }

            return(View());
        }