protected override async Task OnInitializedAsync()
        {
            var data = await TrendingService.GetTrendingItemsAsync("all", "week");

            if (data is not null)
            {
                Results = data;
            }
        }
Exemplo n.º 2
0
        static TagProcessing()
        {
            dataKeyId = 0;
            db        = DataManipulator.loadData();
            //vidi sta se desava kada korisnik doda tag
            AItags = new Dictionary <string, AI>();
            DItags = new Dictionary <string, DI>();

            AIthreads = new Dictionary <string, Thread>();
            DIthreads = new Dictionary <string, Thread>();

            trending = new TrendingService();
            alarming = new AlarmDisplayService();

            foreach (AI ai in db.AIs)
            {
                AItags.Add(ai.Id, ai);
                AIthreads.Add(ai.Id, new Thread(() => readAI(ai.Id)));
            }

            foreach (DI di in db.DIs)
            {
                DItags.Add(di.Id, di);
                DIthreads.Add(di.Id, new Thread(() => readDI(di.Id)));
            }

            //start threads
            foreach (Thread t in AIthreads.Values)
            {
                t.Start();
            }

            foreach (Thread t in DIthreads.Values)
            {
                t.Start();
            }

            Thread saveThread = new Thread(() =>
            {
                while (true)
                {
                    lock (db)
                    {
                        db.SaveChanges();
                    }
                    Thread.Sleep(10000);
                }
            });

            saveThread.Start();
        }
        public async Task WhenGetThenReturnsCorrectData()
        {
            // Arrange
            var responseJson = System.IO.File.ReadAllText("../../../Responses/trending.response.json");

            var factory = TestHelper.GetIHttpClientFactoryMockObject(responseJson);

            var options = Options.Create(new GiphyClientOptions()
            {
                ApiKey = "aaa"
            });
            var client     = new GiphyClient(factory, options);
            var service    = new TrendingService(client);
            var controller = new TrendingController(null, service);

            // Act
            var result = await controller.Get();

            // Assert
            Assert.Equal(TestHelper.JsonToDtosArray(responseJson), result);
        }
Exemplo n.º 4
0
 public TrendingController(ILogger <TrendingController> logger, TrendingService trendingService)
 {
     _logger          = logger;
     _trendingService = trendingService;
 }