public void GetCarousel_WhenCarouselNull_ExpectArgumentNullException()
        {
            _context.Setup(i => i.GetPageContextItem <ICarousel>()).Returns((ICarousel)null);
            var eventsService = new EventsService(_context.Object);

            Assert.ThrowsException <ArgumentNullException>(() => eventsService.GetCarousel());
        }
Exemplo n.º 2
0
        public EventsController()
        {
            // Initialize the GraphServiceClient.
            GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient();

            eventsService = new EventsService(graphClient);
        }
    private IEnumerator _GetUserEvents()
    {
        AlertsService.makeLoadingAlert("Recebendo eventos");
        WWW eventsRequest = EventsService.GetUserEvents(UserService.user._id);

        while (!eventsRequest.isDone)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log("Header: " + eventsRequest.responseHeaders["STATUS"]);
        Debug.Log("Text: " + eventsRequest.text);
        AlertsService.removeLoadingAlert();

        if (eventsRequest.responseHeaders["STATUS"] == HTML.HTTP_200)
        {
            Debug.Log("Received: " + eventsRequest.text);
            EventsService.UpdateUserEvents(eventsRequest.text);
            CreateEventRequestsCards();
        }
        else
        {
            LoadPreviousView();
        }

        yield return(null);
    }
Exemplo n.º 4
0
        public void WhenTryingToRegisterWithAValidCodeReturnsSuccess()
        {
            var service = new EventsService();
            var result  = service.RegisterParticipant("cometothedarksidewehavecookies", "test participant");

            result.ShouldNotBeNull();
        }
Exemplo n.º 5
0
        public void WhenTryingToRegisterWithAnInvalidCodeReturnsError()
        {
            var service = new EventsService();
            var result  = service.RegisterParticipant("bad code", "test participant");

            result.ShouldBeNull();
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public ActionResult View(int DeviceId)
        {
            this._provider = new EventsService(DomainSession.GetAlarmConfigForContextWithDeviceId(this.HttpContext, DeviceId));
            AlarmSystemEventsModel model = new AlarmSystemEventsModel(this._provider.GetAll());

            return(View(model));
        }
Exemplo n.º 8
0
        public ActionResult Index(HttpPostedFileBase file, string parentPath)
        {
            EventsService service = new EventsService();

            using (var reader = new System.IO.StreamReader(file.InputStream))
            {
                var contents = reader.ReadToEnd();
                try
                {
                    IEnumerable <Event> events = JsonConvert.DeserializeObject <IEnumerable <Event> >(contents);

                    var database = Sitecore.Configuration.Factory.GetDatabase("master");
                    var parent   = database.GetItem(parentPath);

                    service.AddItems(parent, events, EventDetails.templateID);
                }
                catch (Exception ex)
                {
                    //to do
                }
            }

            ViewBag.Message = string.Format("{0} updated, {1} added.", service.UpdateCount, service.AddCount);
            return(View());
        }
        public void GetRichEvent_WhenRichEventNull_ExpectArgumentNullException()
        {
            _context.Setup(i => i.GetPageContextItem <IEventDetailsPage>()).Returns((IEventDetailsPage)null);
            var eventsService = new EventsService(_context.Object);

            Assert.ThrowsException <ArgumentNullException>(() => eventsService.GetRichEvent());
        }
        public void SetInfoEventsDisplay_ListaEventos_RegresaMensaje()
        {
            //Arrange
            Mock <IDetermineType>        determineType        = new Mock <IDetermineType>();
            Mock <IValidateDate>         validateDate         = new Mock <IValidateDate>();
            Mock <IDetermineTypeFactory> determineTypeFactory = new Mock <IDetermineTypeFactory>();

            determineType.Setup(x => x.CalculateType(It.IsAny <DateTime>())).Returns(RangeType.Day);
            validateDate.Setup(v => v.SetValueFecha(It.IsAny <string>())).Returns(new DateTime(2020, 01, 28));
            validateDate.Setup(vd => vd.SetMinutes(It.IsAny <DateTime>())).Returns(2.5);
            determineTypeFactory.Setup(f => f.ObtenerInstancia(It.IsAny <RangeType>())).Returns(new HourCalculator(new Util()));

            var SUT = new EventsService(determineType.Object, validateDate.Object, determineTypeFactory.Object);

            //Act
            var resultado = SUT.SetInfoEventsDisplay(new List <Event>()
            {
                new Event()
                {
                    cNombre = "Test", dtFecha = new DateTime(2019, 01, 28)
                }
            });

            //Assert
            Assert.IsTrue(resultado[0].cMensaje != string.Empty);
        }
        public void GetEventById_ShouldReturnSingleEventWithTheGivenId()
        {
            var context = new EventuresDbContext(this.Options);

            var events = new List <Event>
            {
                new Event {
                    Id = "1", Name = "Event1"
                },
                new Event {
                    Id = "2", Name = "Event2"
                },
                new Event {
                    Id = "3", Name = "Event3"
                },
            };

            context.Events.AddRange(events);
            context.SaveChanges();

            var service = new EventsService(context);

            var resultEvent = service.GetEventById("1");

            Assert.Equal(events[0], resultEvent);
            Assert.Equal(events[0].Name, resultEvent.Name);
        }
Exemplo n.º 12
0
        public async Task CreateAsyncShouldCreateNewWallPost()
        {
            var post        = new Post();
            var postService = new Mock <IWallPostsService>();

            postService
            .Setup(r
                   => r.CreateAsync(It.IsAny <string>(), It.IsAny <PostType>(), It.IsAny <int?>(), It.IsAny <string>()))
            .Callback <string, PostType, int?, string>((c, t, a, o) =>
            {
                post.UserId         = c;
                post.PostType       = t;
                post.AssignedEntity = a;
                post.Content        = o;
            });

            var service = new EventsService(
                this.eventsRepository,
                postService.Object,
                this.postRepository);
            await service.CreateAsync(
                "ttt", "yyyy", DateTime.Now, DateTime.Today, false, false, "ooo", "www", new List <string>());

            Assert.Equal("ooo", post.UserId);
            Assert.Equal(PostType.NewEvent, post.PostType);
            Assert.Null(post.Content);
        }
        public async Task Create_WithInvalidModel_ShouldNotAddToDatabase()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <EventuresDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var context       = new EventuresDbContext(options);
            var eventsService = new EventsService(context);
            var model         = new EventuresEventServiceModel
            {
                Name           = "Test Event",
                Place          = "Test Place",
                StartDate      = DateTime.UtcNow,
                EndDate        = DateTime.UtcNow,
                TotalTickets   = -1,
                PricePerTicket = 1
            };

            // Act
            await eventsService.CreateAsync(model);

            // Assert
            var count = await context.Events.CountAsync();

            Assert.Equal(0, count);
        }
Exemplo n.º 14
0
    private IEnumerator _GetEvents()
    {
        AlertsService.makeLoadingAlert("Recebendo eventos");
        WWW eventsRequest = EventsService.GetEvents();

        while (!eventsRequest.isDone)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log("Header: " + eventsRequest.responseHeaders["STATUS"]);
        Debug.Log("Text: " + eventsRequest.text);
        AlertsService.removeLoadingAlert();

        if (eventsRequest.responseHeaders["STATUS"] == HTML.HTTP_200)
        {
            StartCoroutine(_GetUserEvents());
            EventsService.UpdateLocalEvents(eventsRequest.text);
            CreateEventCards();
        }
        else
        {
            AlertsService.makeAlert("Falha na conexão", "Tente novamente mais tarde.", "");
            yield return(new WaitForSeconds(3f));

            LoadView("Home");
        }

        yield return(null);
    }
Exemplo n.º 15
0
    private IEnumerator _GetUserEvents()
    {
        AlertsService.makeLoadingAlert("Recebendo eventos");
        WWW eventsRequest = EventsService.GetUserEvents(UserService.user._id);

        while (!eventsRequest.isDone)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log("Header: " + eventsRequest.responseHeaders["STATUS"]);
        Debug.Log("Text: " + eventsRequest.text);
        AlertsService.removeLoadingAlert();

        if (eventsRequest.responseHeaders["STATUS"] == HTML.HTTP_200)
        {
            EventsService.UpdateUserEvents(eventsRequest.text);
        }
        else
        {
            AlertsService.makeAlert("Alerta", "Por conta de um erro em sua conexão, novos pedidos de participação em eventos serão negados por enquanto.", "Entendi");
        }

        yield return(null);
    }
Exemplo n.º 16
0
        private static async Task Main(string[] args)
        {
            if (args.Length < 1)
            {
                System.Console.WriteLine("Must enter api url");
                return;
            }

            ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true;

            _eventsService = new EventsService(args[0]);
            var username    = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            var machineName = System.Environment.MachineName;

            _userId = await _eventsService.GetUserId(username,
                                                     machineName);

            _windowHelper = new WindowHelper();
            var startingApplicationName = _windowHelper.GetActiveWindowApplication();

            _applicationId = await GetApplicationId(startingApplicationName);

            System.Console.WriteLine($"Listening started for {username} on {machineName} with {startingApplicationName}");

            var inputStateManager = new InputStateManager(startingApplicationName, 120000, 5000);

            inputStateManager.InputStarted       += OnInputStarted;
            inputStateManager.InputUpdated       += OnInputUpdated;
            inputStateManager.ApplicationChanged += OnApplicationChanged;

            do
            {
                // spin
            } while (System.Console.ReadKey(true).Key != ConsoleKey.Escape);
        }
Exemplo n.º 17
0
        public ActionResult DeleteItem(string Id)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Events model          = new Events()
            {
                Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString())
            };

            try
            {
                if (model.Id > 0)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    EventsService.DeleteItem(model);
                    TempData["MessageSuccess"] = "Xóa thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Xóa Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch {
                TempData["MessageSuccess"] = "Xóa không thành công";
                return(Json(new MsgError()));
            }
        }
Exemplo n.º 18
0
        public ActionResult SaveItem(Events model)
        {
            string      ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int         IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            EventsModel data           = new EventsModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    EventsService.SaveItem(model);
                    if (model.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index"));
                }
            }
            return(View(data));
        }
Exemplo n.º 19
0
        public ActionResult UpdateStatus([FromQuery] string Ids, Boolean Status)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Events item           = new Events()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Status = Status
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateStatus = EventsService.UpdateStatus(item);
                    TempData["MessageSuccess"] = "Cập nhật Trạng Thái thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Cập nhật Trạng Thái Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch
            {
                TempData["MessageSuccess"] = "Cập nhật Trạng Thái không thành công";
                return(Json(new MsgError()));
            }
        }
 public void CanIDownloadAListOfEvents()
 {
     var request = new EventRequest();
     var target = new EventsService();
     var actual = target.OnGet(request);
     Assert.IsNotNull(actual);
 }
Exemplo n.º 21
0
        public async Task <IActionResult> Logout(LogoutInputModel model)
        {
            var vm = await AccountService.BuildLoggedOutViewModelAsync(model.LogoutId);

            if (vm.TriggerExternalSignout)
            {
                var url = Url.Action("Logout", new { logoutId = vm.LogoutId });
                try
                {
                    // hack: try/catch to handle social providers that throw
                    await HttpContext.Authentication.SignOutAsync(vm.ExternalAuthenticationScheme,
                                                                  new AuthenticationProperties { RedirectUri = url });
                }
                catch (NotSupportedException) // this is for the external providers that don't have signout
                {
                }
                catch (InvalidOperationException) // this is for Windows/Negotiate
                {
                }
            }

            // delete local authentication cookie
            await HttpContext.Authentication.SignOutAsync();

            var user = await HttpContext.GetIdentityServerUserAsync();

            if (user != null)
            {
                await EventsService.RaiseAsync(new UserLogoutSuccessEvent(user.GetSubjectId(), user.GetName()));
            }

            return(View("LoggedOut", vm));
        }
        public async Task GetAllOrderedByStart_ShouldReturnOrderedByStartList()
        {
            var context = new EventuresDbContext(this.Options);

            var events = new List <Event>
            {
                new Event
                {
                    Start = DateTime.UtcNow.AddDays(1)
                },
                new Event
                {
                    Start = DateTime.UtcNow.AddDays(3)
                },
                new Event
                {
                    Start = DateTime.UtcNow.AddDays(2)
                },
            };
            await context.Events.AddRangeAsync(events);

            await context.SaveChangesAsync();

            var eventsService = new EventsService(context);

            var serviceResult = eventsService.GetAllOrderedByStart();

            var expected = events.OrderBy(e => e.Start);

            Assert.Equal(expected, serviceResult);
        }
        public void GetUpcomingEvents_WhenUpcomingEventsNull_ExpectArgumentNullException()
        {
            _context.Setup(i => i.GetPageContextItem <IUpcomingEvents>()).Returns((IUpcomingEvents)null);
            var eventsService = new EventsService(_context.Object);

            Assert.ThrowsException <ArgumentNullException>(() => eventsService.GetUpcomingEvents());
        }
Exemplo n.º 24
0
        public void EventsService_GetState_GetTimeSinceActive_Blank_Invalid()
        {
            EventsService es = new EventsService();

            var timeUntilActive = es.GetTimeSinceActive(new WorldBossEvent());

            Assert.AreEqual(TimeSpan.MinValue, timeUntilActive);
        }
Exemplo n.º 25
0
        public void EventsService_GetState_GetTimeSinceActive_Null_Invalid()
        {
            EventsService es = new EventsService();

            var timeUntilActive = es.GetTimeSinceActive(null);

            Assert.AreEqual(TimeSpan.MinValue, timeUntilActive);
        }
        public void GetRichEvent_WhenRichEventNotNull_ExpectRichEventElement()
        {
            var eventsService = new EventsService(_context.Object);

            var result = eventsService.GetRichEvent();

            Assert.IsNotNull(result);
        }
Exemplo n.º 27
0
        public async Task CreateEventShouldReturnOne()
        {
            var service = new EventsService(this._dbContext, this._mapper, this._moviesService, this._peopleService);

            var result = await service.CreateEvent(new CreateEventViewModel());

            Assert.Equal(1, result);
        }
Exemplo n.º 28
0
        public void GetUpcomingEventsReturnsListFromServer()
        {
            var mockHttpMessageHandler = new MockHttpMessageHandlerFactory();
            var eventService           = new EventsService(mockHttpMessageHandler);
            var events = eventService.GetUpcomingEvents().Result;

            Assert.IsNotEmpty(events.Data);
        }
Exemplo n.º 29
0
 public EventsContentViewModel(INavigationService navigationService, IPageDialogService dialogService)
 {
     _navigation        = navigationService;
     _dialogService     = dialogService;
     SelectEventCommand = new Command(async(i) => { await OnSelectEvent((EventsModel)i); });
     _eventsService     = new EventsService();
     LoadEvents();
 }
Exemplo n.º 30
0
 public EventsServiceSpec()
 {
     messageBusListenerBuilderMock = new Mock <IMessageBusListenerBuilder>();
     messageBusListenerMock        = new Mock <IMessageBusListener>();
     loggerMock = new Mock <ILogger <EventsService> >();
     messageBusListenerBuilderMock.Setup(x => x.Build())
     .Returns(messageBusListenerMock.Object);
     sut = new EventsService(loggerMock.Object, messageBusListenerBuilderMock.Object);
 }
        public async Task CreateMethod_ShouldAddEventToContext()
        {
            var context = new EventuresDbContext(this.Options);

            var eventsService = new EventsService(context);
            await eventsService.CreateAsync("Name", "Place", 10.00m, 100, DateTime.UtcNow, DateTime.UtcNow.AddDays(3));

            Assert.Equal(1, context.Events.Count());
        }
        public void GetEvents_Caches_Results()
        {
            //Arrange
            var eventsRepo = new StubIRepository<Event>()
            {
                All = () => EventTestData.SingleEvent.AsQueryable()
            };
            var cacheService = new DefaultMemoryCache();
            var eventService = new EventsService(eventsRepo, cacheService);

            //Act
            eventService.GetEvents();
            //Assert
            Assert.IsTrue(cacheService.Exists("events:all"));
        }
        public void GetEvents_Returns_Results_From_Cache()
        {
            //arrange
            var cacheService = new StubICacheService()
            {
                ExistsString = (key) => true
            };

            cacheService.RetrieveOf1String<IEnumerable<Event>>(
                (key) => EventTestData.SingleEvent.AsEnumerable()
            );
            var eventsRepo = new StubIRepository<Event>();
            var eventService = new EventsService(eventsRepo, cacheService);

            //Act
            var results = eventService.GetEvents();
            Assert.AreEqual(results.Count(), EventTestData.SingleEvent.Count);
        }
        public void GetEvents_Does_Not_Call_Repository_All_When_Cache_Available()
        {
            //arrange
            var cacheService = new DefaultMemoryCache();
            cacheService.Store("events:all", EventTestData.SingleEvent.AsQueryable());
            bool allWasCalled = false;
            var eventsRepo = new StubIRepository<Event>()
            {
                All = () =>
                {
                    allWasCalled = true;
                    return Enumerable.Empty<Event>().AsQueryable();
                }
            };
            var eventService = new EventsService(eventsRepo, cacheService);

            //Act
            var results = eventService.GetEvents();

            //Assert
            Assert.IsFalse(allWasCalled);
        }
 public override void TestInit()
 {
     this.EventsService = new EventsService();
     this.currentuser = new TestUser();
 }
        public void GetPastEvents_Only_Returns_Previous_Events()
        {
            //Arrange
            var cacheService = new StubICacheService();
            var eventsRepo = new StubIRepository<Event>()
            {
                FindExpressionOfFuncOfT0Boolean = (func) => EventTestData.MultipleEvents.AsQueryable().Where(func)
            };
            var eventService = new EventsService(eventsRepo, cacheService);

            //act
            using (ShimsContext.Create())
            {
                //Set current DateTime.Now to 12/12/12
                ShimDateTime.NowGet = () => new DateTime(2012, 12, 12);
                var results = eventService.GetPastEvents();

                //assert
                Assert.AreEqual(2, results.Count());

            }
        }