public void CallStatisticRepository_AddOnce() { // Arrange var mockedUserService = new Mock <IUserService>(); var user = new CustomUser() { Id = 1 }; mockedUserService.Setup(x => x.GetByIndentityId(It.IsAny <string>())).Returns(user); var mockedStatisticRepository = new Mock <IEFRepository <Statistic> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedStatisticFactory = new Mock <IStatisticFactory>(); var statistic = new Statistic(); mockedStatisticFactory.Setup(x => x.CreateStatistic(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns(statistic); var statisticService = new StatisticService( mockedUserService.Object, mockedStatisticRepository.Object, mockedUnitOfWork.Object, mockedStatisticFactory.Object); string userId = "some-id"; // Act statisticService.CreateStatistic(userId); // Assert mockedStatisticRepository.Verify(x => x.Add(It.Is <Statistic>(s => s == statistic)), Times.Once); }
public TipViewModel(RestService reset, SoundService sound, ConfigService config, StatisticService statistic, MainService main, App app, KeyboardShortcutsService keyboardShortcuts, PreAlertService preAlert, ThemeService theme) { this.reset = reset; this.reset.TimeChanged += new RestEventHandler(timeChanged); this.reset.RestCompleted += new RestEventHandler(resetCompleted); this.sound = sound; this.config = config; this.config.Changed += config_Changed; resetCommand = new Command(new Action <object>(resetCommand_action)); busyCommand = new Command(new Action <object>(busyCommand_action)); this.statistic = statistic; this.main = main; this.keyboardShortcuts = keyboardShortcuts; this.preAlert = preAlert; this.theme = theme; theme.OnChangedTheme += Theme_OnChangedTheme; ChangedEvent += TipViewModel_ChangedEvent; LoadConfig(); }
public Home() { this.InitializeComponent(); Logger.InitLogger(); this._userService = new UserService(); this._drunkDrinksService = new DrunkDrinkService(); this._statisticService = new StatisticService(); if (Application.Current.Properties["userId"] != null) { int id = (int)Application.Current.Properties["userId"]; try { this.GoalLabel.Content = this._userService.GetUserInfo(id).Goal; this.WaterNormLabel.Content = this._userService.GetUserData(id).WaterNorm; } catch (Exception e) { Logger.Log.Error(e.Message); this.GoalLabel.Content = 2000; } } ShowHistory(); int percent = _drunkDrinksService.CurrentlyPercent(); DailyInTake2.Text = percent + "%"; }
private void DisplayAnswer() { lv_testResult.Items.Clear(); QuestionService questionService = new QuestionService(); List <QuestionModel> questionList = questionService.GetAll().Where(x => x.TestID == testID).ToList(); AnswerService answerService = new AnswerService(); List <AnswerModel> answerList = answerService.GetAll().ToList(); UserService userService = new UserService(); lbl_userName.Text = userService.Get(userID).Name; StatisticService statisticService = new StatisticService(); int correct = statisticService.GetAll() .Where(x => x.TestID == testID && x.UserID == userID) .OrderByDescending(x => x.StatisticID) .First().CorrectAnswer; lbl_result.Text += Math.Round((double)(100 * correct) / questionList.Count).ToString() + "%"; foreach (var question in questionList) { string correctAnswer = answerList.Where(x => x.QuestionID == question.QuestionID && x.isCorrect == true).Single().AnswerText; var row = new string[] { question.QuestionName, correctAnswer }; ListViewItem listView = new ListViewItem(row); listView.Tag = question; lv_testResult.Items.Add(listView); } }
protected void Page_Load(object sender, EventArgs e) { lBase.Text = string.Format("<base href='{0}'/>", Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + (!Request.ApplicationPath.EndsWith("/") ? "/" : string.Empty) + "admin/"); MenuAdmin.CurrentCustomer = CustomerContext.CurrentCustomer; newAdminMessage = AdminMessagesService.GetNotViewedAdminMessagesCount(); newReviewsCount = StatisticService.GetLastReviewsCount(); adminMessages.CssClass = "top-part-right icon-mail " + (newAdminMessage > 0 ? "icon-selected" : ""); adminMessages.Text = newAdminMessage > 0 ? newAdminMessage.ToString() : ""; adminMessages.Visible = AdvantshopConfigService.GetLocalization() == "ru-RU"; adminReviews.CssClass = "top-part-right icon-bubble " + (newReviewsCount > 0 ? "icon-selected" : ""); adminReviews.Text = newReviewsCount > 0 ? newReviewsCount.ToString() : ""; var _customer = CustomerContext.CurrentCustomer; if (_customer.CustomerRole == Role.Moderator) { var actions = RoleActionService.GetCustomerRoleActionsByCustomerId(_customer.Id); bool visible = actions.Any(a => a.Key == RoleActionKey.DisplayAdminMainPageStatistics && a.Enabled); StoreLanguage.Visible = visible; LastAdminMessages.Visible = visible; adminMessages.Visible = visible; adminReviews.Visible = actions.Any(a => a.Key == RoleActionKey.DisplayComments && a.Enabled); } }
/// <summary> /// Die Daten eines Elements analysieren und daraus ein Objekt erstellen. /// </summary> /// <param name="id">Die ID des Element, zum Beispiel GR_389F860B088563B1.</param> /// <returns>Ein Objekt, das die Daten des Elements in Enable Now enthält</returns> internal async Task <Element> CrawlElementAsync(string id) { Element element = new(id); FillInitialFields(element); MetaDataCollection metaData = await MetaAnalyzer.LoadMetaFilesAsync(element); FillFields(element, metaData); AddAssets(element, metaData); string autostartId = GetAutostartId(metaData); StatisticService statisticService = StatisticService.GetService(_jobConfig.Id); if (autostartId != null) { try { Element autostartElement = await CrawlElementAsync(autostartId); OverwriteValuesByAutostartElement(element, autostartElement); statisticService.IncreaseAutostartElementsCount(); } catch { _log.Warn(LocalizationService.FormatResourceString("ElementCrawlerMessage01")); } } element.Hash = element.GenerateHashCode(); SetDateValue(element); statisticService.IncreaseFoundDocumentsCount(); return(element); }
public GetActivityFeedQueryHandler( IStorageAccessService storageAccessService, StatisticService statisticService) { this.storageAccessService = storageAccessService ?? throw new ArgumentNullException(nameof(storageAccessService)); this.statisticService = statisticService ?? throw new ArgumentNullException(nameof(statisticService)); }
public void GetAllByUserIdUnit() { var managerMock = new DataManagerMock(new AnswersRepositoryMock(), new QuestionsRepositoryMock(), new TestsRepositoryMock(), new StatisticRepositoryMock(), new UsersRepositoryMock(), new WrittenLetterRepositoryMock()); var statisticService = new StatisticService(managerMock); StatiscticViewModel model = new StatiscticViewModel() { testId = 1, ownerId = "1", Result = 1, PassedAt = DateTime.Parse("01/01/2021") }; StatiscticViewModel model2 = new StatiscticViewModel() { testId = 2, ownerId = "1", Result = 2, PassedAt = DateTime.Parse("01/01/2021") }; const string userId = "1"; var actual = statisticService.GetAllByUserId(userId); Assert.Equal(actual[0].testId, model.testId); Assert.Equal(actual[0].ownerId, model.ownerId); Assert.Equal(actual[0].Result, model.Result); Assert.Equal(actual[1].testId, model2.testId); Assert.Equal(actual[1].ownerId, model2.ownerId); Assert.Equal(actual[1].Result, model2.Result); }
public async void GetAverageFriendsPerUser() { var service = new StatisticService(datasetRepository); var result = await service.GetAverageFriendsPerUser("datasetId"); Assert.Equal(1.33, Math.Round(result, 2)); }
static void Main(string[] args) { // user input IStatisticService statisticService = new StatisticService(); IFunctionalityService functionalityService = new FunctionalityService(); functionalityService.Notification += NotificationManager.Show; var user = new User("Name", 70.1, 160, 20, Gender.Male); // user input by while var run = new Run { Name = "Minsk Marathon", Speed = 10.2 }; var time1 = 4000; // 4000 ms = 4 sec run.Start = functionalityService.Execute($"Start {run.Name}: "); Thread.Sleep(time1); run.End = functionalityService.Execute($"End {run.Name}: "); run.Data = (decimal)(time1 * run.Speed); user.Runs.Add(run); functionalityService.ShowRuns(user); var exercise = new Exercise { Name = "Jump", Count = 200, }; var time2 = 5000; exercise.Start = functionalityService.Execute($"Start {exercise.Name}: "); Thread.Sleep(time2); exercise.End = functionalityService.Execute($"End {exercise.Name}: "); exercise.Data = ((double)exercise.Count / time2) * 1000; user.Exercises.Add(exercise); Console.WriteLine("\n=======\n"); functionalityService.ShowAll(user); Console.WriteLine("\n=======\n"); var bioTrackerData = functionalityService.BioTrackerPpg(); foreach (var val in bioTrackerData) { Console.WriteLine(val); } Console.WriteLine("\n=======\n"); var statistic = statisticService.Get(user, bioTrackerData); Console.ReadKey(); }
public StatisticViewModel( StatisticService statistic, ConfigService config, TomatoService tomato) { this.statistic = statistic; this.config = config; this.tomato = tomato; yearmonth = DateTime.Now.Year + DateTime.Now.Month; CloseOnboardingCommand = new Command(new Action <object>(OnCloseOnboardingCommand)); GenerateMonthlyDataImgCommand = new Command(new Action <object>(OnGenerateMonthlyDataImgCommand)); Data = new StatisticModel(); Data.Year = DateTime.Now.Year; Data.Month = DateTime.Now.Month; Data.MonthRestData = new List <ChartDataModel>(); Data.MonthWorkData = new List <ChartDataModel>(); Data.MonthSkipData = new List <ChartDataModel>(); Data.WeekRestData = new List <ChartDataModel>(); Data.WeekWorkData = new List <ChartDataModel>(); Data.WeekSkipData = new List <ChartDataModel>(); Data.TomatoWeekData = new List <ChartDataModel>(); Data.PropertyChanged += Data_PropertyChanged; Data.IsAnimation = config.options.Style.IsAnimation; MigrateCheck(); HandleMonthData(); HandleWeekData(); Analysis(); }
/// <summary> /// Creates the requested service if not already created and returns it. /// </summary> /// <param name="type"></param> /// <returns></returns> public static StatisticService GetService(Type type) { lock (services) { if (services.ContainsKey(type)) { // Return already created statistic service. return(services[type]); } else { // Create and return requested service. if (!type.IsSubclassOf(typeof(StatisticService))) { throw new ArgumentException("Requested service not based on StatisticsService.", "type"); } StatisticService service = (StatisticService)Activator.CreateInstance(type); if (null != service) { services.Add(type, service); } return(service); } } }
public void CallUserService_GetByIndentityIdOnce() { // Arrange var mockedUserService = new Mock <IUserService>(); var user = new CustomUser() { Id = 1 }; mockedUserService.Setup(x => x.GetByIndentityId(It.IsAny <string>())).Returns(user); var mockedStatisticRepository = new Mock <IEFRepository <Statistic> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedStatisticFactory = new Mock <IStatisticFactory>(); var statisticService = new StatisticService( mockedUserService.Object, mockedStatisticRepository.Object, mockedUnitOfWork.Object, mockedStatisticFactory.Object); string userId = "some-id"; // Act statisticService.GetUserStatistic(userId); // Assert mockedUserService.Verify(x => x.GetByIndentityId(It.Is <string>(i => i == userId)), Times.Once); }
protected void Page_PreRender(object sender, EventArgs e) { DateTime now = DateTime.Now; lblSaleToday.Text = Convert.ToString(StatisticService.GetOrdersCountByDate(now)); lSumToday.Text = CatalogService.GetStringPrice(StatisticService.GetOrdersSumByDate(now)); lblSaleYesterday.Text = Convert.ToString(StatisticService.GetOrdersCountByDate(now.AddDays(-1))); lSumYesterday.Text = CatalogService.GetStringPrice(StatisticService.GetOrdersSumByDate(now.AddDays(-1))); lblSaleWeek.Text = Convert.ToString( StatisticService.GetOrdersCountByDateRange( now.StartOfWeek(Culture.Language == Culture.SupportLanguage.English ? DayOfWeek.Sunday : DayOfWeek.Monday), now)); lSumWeek.Text = CatalogService.GetStringPrice( StatisticService.GetOrdersSumByDateRange( now.StartOfWeek(Culture.Language == Culture.SupportLanguage.English ? DayOfWeek.Sunday : DayOfWeek.Monday), now)); lblSaleMounth.Text = Convert.ToString(StatisticService.GetOrdersCountByDateRange(new DateTime(now.Year, now.Month, 1), now)); lSumMonth.Text = CatalogService.GetStringPrice(StatisticService.GetOrdersSumByDateRange(new DateTime(now.Year, now.Month, 1), now)); lblSale.Text = Convert.ToString(StatisticService.GetOrdersCountByDateRange(now.AddYears(-100), now)); lSaleSum.Text = CatalogService.GetStringPrice(StatisticService.GetOrdersSumByDateRange(now.AddYears(-100), now)); lblTotalProducts.Text = Convert.ToString(StatisticService.GetProductsCount()); }
/// <summary> /// /// </summary> /// <param name="element"></param> /// <returns></returns> internal async Task <List <Element> > CrawlAttachementsAsync(Element element) { ConverterService converter = new(); List <Element> attachements = new(); StatisticService statisticService = StatisticService.GetService(_jobConfig.Id); foreach (var attachementName in element.AttachementNames) { ConverterResult res; try { res = await converter.ConvertAttachementAsync(element, attachementName); } catch { _log.Error(LocalizationService.FormatResourceString("AttachementCrawlerMessage01", attachementName, element.Id)); ErrorControlService.GetService().IncreaseErrorCount(); continue; } Element attachement = element.Clone() as Element; OverwriteAttachementValues(attachement, res, attachementName); attachements.Add(attachement); statisticService.IncreaseFoundDocumentsCount(); } return(attachements); }
public PodcastController( IRepositoryWrapper repoWrapper, IWebHostEnvironment appEnvironmente) { _repoWrapper = repoWrapper; _appEnvironment = appEnvironmente; _statisticService = new StatisticService(_repoWrapper); }
/// <summary> /// /// </summary> /// <param name="id"></param> internal void RemoveElementCompletly(string id) { _log.Debug(LocalizationService.FormatResourceString("CrawlerIndexerInterfaceMessage04", id)); using ElementLogContext context = new(); context.RemoveElementLog(id, _jobConfig.Id); _indexer.RemoveElementFromIndexAsync(id); StatisticService.GetService(_jobConfig.Id).IncreaseRemovedDocumentsCount(); }
public void GetReadedBooksTestMethod2() { IStatisticService serv = new StatisticService(); List <BookDTO> books = serv.GetReadedBooks(1).ToList(); int len = books.Count; int expected = 3; Assert.AreNotEqual(expected, len); }
public DatabaseManager(DbModelContainer dbContext, Encryption encryption, PartyService partyService, VoterService voterService, CandidateService candidateService, StatisticService statisticService) { _dbContext = dbContext; Party = partyService; Voter = voterService; Candidate = candidateService; Statistic = statisticService; }
/// <summary> /// Create and return an instance of IStatisticService /// </summary> /// <returns></returns> public static IStatisticService createIStatisticService() { var statisticService = new StatisticService(createIRequirementsRepository(), createIProjectRepository()); statisticService.GlobalResources = createIResource(); statisticService.DbContext = createIDbContext(); return(statisticService); }
public StatisticViewModel(StatisticService statistic) { this.statistic = statistic; Data = new StatisticModel(); Data.Working = statistic.GetChartData(StatisticType.WorkingTime); Data.Reset = statistic.GetChartData(StatisticType.ResetTime); Data.Skip = statistic.GetChartData(StatisticType.SkipCount); Data.Labels = statistic.GetChartLabels(); }
public void TestgetInstallationState() { Init(); StatisticService sservice = new StatisticService(mockirepo, mockmrepo, mockmtrepo); Dictionary <InstallationModel, List <InstallationState> > ilist = sservice.getInstallationState(0); Assert.IsNotNull(ilist); Assert.AreEqual(1, ilist.Count); }
public void TestgetStatisticsperDay() { Init(); StatisticService sservice = new StatisticService(mockirepo, mockmrepo, mockmtrepo); Dictionary <InstallationModel, List <Statistic> > slist = sservice.getStatisticPerDay(0, DateTime.Now); Assert.IsNotNull(slist); Assert.AreEqual(1, slist.Count); }
public ServicesManager(DataManager dataManager) { this.dataManager = dataManager; this.testService = new TestService(this.dataManager); this.questionService = new QuestionService(this.dataManager); this.answerService = new AnswerService(this.dataManager); this.writtenLetterService = new WrittenLetterService(this.dataManager); this.statisticService = new StatisticService(this.dataManager); this.userService = new UserService(this.dataManager); }
public ResultObj <List <ClassModel> > GetPayNumbersByDate(string salesDateStart = "", string salesDateEnd = "", string type = "year", string clientId = "") { if (string.IsNullOrEmpty(salesDateStart) || string.IsNullOrEmpty(salesDateEnd) || string.IsNullOrEmpty(type)) { return(null); } IStatistic istatistic = new StatisticService(); return(Content(istatistic.GetPayNumbersByDate(salesDateStart, salesDateEnd, type, clientId))); }
public ResultObj <List <ClassModel> > GetGroupMoneyByMachine(string salesDateStart = "", string salesDateEnd = "", string clientId = "", bool needPage = true, int pageIndex = 1, int pageSize = 10) { if (string.IsNullOrEmpty(salesDateStart) || string.IsNullOrEmpty(salesDateEnd)) { return(null); } IStatistic istatistic = new StatisticService(); return(Content(istatistic.GetGroupMoneyByMachine(salesDateStart, salesDateEnd, clientId, needPage, pageIndex, pageSize))); }
public override void Enter() { StatisticService.GetLeaderboard(StatisticType.HourTime.ToString()) .Then(result => leaderboardScreenController.ShowGlobalLeaderboard(result)) .Catch(error => leaderboardScreenController.HideGlobalLeaderboard()); StatisticService.GetPlayerLeaderboard(StatisticType.HourTime.ToString(), 1) .Then(result => leaderboardScreenController.ShowPlayerLeaderboard(result)) .Catch(error => leaderboardScreenController.HidePlayerLeaderboard()); leaderboardScreenController.Load(); }
public void Setup() { MapperConfiguration mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingStatistic <StatisticData>()); }); IMapper mapper = mappingConfig.CreateMapper(); statisticService = new StatisticService <StatisticData>(workingWithStatisticForTest, mapper); }
public void UsersStatisticTest() { StatisticService statistic = new StatisticService(); var usersStatistic = statistic.GetUsersStatistic().ToList(); int winnersFirstUser = usersStatistic.First(t => t.Id == 1).NumOfDogsWinners; Assert.AreEqual(2, winnersFirstUser); int winnersSecondUser = usersStatistic.First(t => t.Id == 2).NumOfDogsWinners; Assert.AreEqual(1, winnersSecondUser); }
public StatisticForm(StatisticService current, DrawService drawing) { InitializeComponent(); service = current; draw = drawing; this.chart1.ChartAreas[0].AxisX.Title = "ітерація"; this.chart1.ChartAreas[0].AxisY.Title = "кількість агентів"; DataBinding(); }
public ServicesManager(DataManager dataManager) { _dataManager = dataManager; _statisticService = new StatisticService(dataManager); _answerService = new AnswerService(_dataManager); _testService = new TestService(_dataManager); _questionService = new QuestionService(_dataManager); _userService = new UserService(_dataManager); _correctAnswerService = new CorrectAnswerService(_dataManager); _userTestAccessService = new UserTestAccessService(_dataManager); }
public void DogsStatisticTests() { StatisticService statistic = new StatisticService(); var dogsStatistic = statistic.GetDogsStatistic().ToList(); int winners3Dog = dogsStatistic.First(t => t.Id == 3).NumOfVictories; Assert.AreEqual(2, winners3Dog); int winners2Dog = dogsStatistic.First(t => t.Id == 2).NumOfVictories; Assert.AreEqual(1, winners2Dog); int winners1Dog = dogsStatistic.First(t => t.Id == 1).NumOfVictories; Assert.AreEqual(1, winners1Dog); }