public void GetFlagsDoesNotAddUrgentCoverFlagToCoveredEvent() { var testEvent = GetTestEvent(); var urgentThreshold = 15; var options = new FlagServiceOptions { UrgentCoverThreshold = urgentThreshold }; testEvent.Date = DateTime.Today.AddDays(urgentThreshold - 1); testEvent.Deployments.Clear(); testEvent.Deployments.Add(_fixture.Create <Deployment>()); testEvent.Deployments.Add(_fixture.Create <Deployment>()); testEvent.Deployments.Add(_fixture.Create <Deployment>()); testEvent.CyclistsRequested = 3; testEvent.DateConfirmed = true; var expectedFlag = Flags.UrgentCoverNeeded; var flagService = new FlagService(Options.Create(options)); var actualFlag = flagService.GetFlags(testEvent, expectedFlag); actualFlag.Should().NotContain(expectedFlag); }
private async void CountrySearch_TextChanged(object sender, TextChangedEventArgs e) { _cancellationTokenSource?.Cancel(); _cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = _cancellationTokenSource.Token; try { await Task.Delay(500, cancellationToken); if (cancellationToken.IsCancellationRequested) { return; } var countries = await Task.Run(async() => await FlagService.GetFlagsTask(e.NewTextValue), cancellationToken); if (cancellationToken.IsCancellationRequested) { return; } Device.BeginInvokeOnMainThread(() => Countries.ReplaceRange(countries)); } catch (OperationCanceledException) { // we cancelled so do nothing... (ugly!) } }
public TestSetup() { var dataContext = new FakeDataContext(); AnswerFlagsRepository = new Repository <AnswerFlag>(dataContext); AnswerDescriptionFlagRepository = new Repository <AnswerDescriptionFlag>(dataContext); CacheMock = new TestCacheManager().CacheMock; TestLoggerFactory = new TestLoggerFactory(); AnswerDescriptionServiceMock = new Mock <IAnswerDescriptionService>(); // Suppose we always adding answer 15 AnswerDescriptionServiceMock.Setup( x => x.FindByAnswerDescriptionId(It.IsAny <int>()) ).Returns(new AnswerDescriptionDto() { AnswerId = EXISTING_ANSWER_ID }); TestLoggerFactory = new TestLoggerFactory(); FlagService = new FlagService( AnswerDescriptionServiceMock.Object, CacheMock.Object, AnswerFlagsRepository, AnswerDescriptionFlagRepository, TestLoggerFactory); }
public void GetFlagsDoesNotAddBriefingNotesReadyIfEventIsDistant() { var testEvent = GetTestEvent(); var notesThreshold = 14; var options = new FlagServiceOptions { SendBriefingNotesThreshold = notesThreshold }; testEvent.Date = DateTime.Today.AddDays(notesThreshold + 1); testEvent.Schedule.Add(_fixture.Create <ScheduleItem>()); testEvent.Deployments.Add(_fixture.Create <Deployment>()); testEvent.ExpectedIncidents.Add(_fixture.Create <ExpectedIncident>()); testEvent.BriefingNotesSent = false; var expectedFlag = Flags.BriefingNotesReady; var flagService = new FlagService(Options.Create(options)); var actualFlag = flagService.GetFlags(testEvent, expectedFlag); actualFlag.Should().NotContain(expectedFlag); }
private async void CountrySearch_TextChanged(object sender, TextChangedEventArgs e) { await Task.Delay(500); var countries = await FlagService.GetFlagsTask(e.NewTextValue); Device.BeginInvokeOnMainThread(() => Countries.ReplaceRange(countries)); }
public IHttpActionResult Update(int id, FlagModel flag) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ResponseModel response = FlagService.UpdateFlag(id, flag); return(Ok(response)); }
//Source: https://byteloom.marek-mierzwa.com/mobile/2018/06/18/search-as-you-type-in-xamarin-forms.html private async void CountrySearch_TextChanged(object sender, TextChangedEventArgs e) { _cancellationTokenSource?.Cancel(); if (e.NewTextValue.Length < 3 && searchTerm == e.NewTextValue) { return; } _cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = _cancellationTokenSource.Token; try { await Task.Delay(500, cancellationToken); searchTerm = e.NewTextValue; if (cancellationToken.IsCancellationRequested) { return; } var timeoutTask = Task.Delay(TimeSpan.FromSeconds(30), cancellationToken); var countriesTask = Task.Run(async() => await FlagService.GetFlagsTask(e.NewTextValue), cancellationToken); if (await Task.WhenAny(countriesTask, timeoutTask) == timeoutTask) { throw new TimeoutException(); } if (cancellationToken.IsCancellationRequested) { return; } var countries = await countriesTask; Device.BeginInvokeOnMainThread(() => Countries.ReplaceRange(countries)); } catch (OperationCanceledException) { // we cancelled so do nothing... (ugly!) } catch (TimeoutException timeoutEx) { //Handle timeout here... Console.WriteLine("Timeout!"); } }
public IHttpActionResult Create(FlagModel flag) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ResponseModel response = FlagService.CreateFlag(flag); return(Ok(response)); //return Ok(customerFake); }
/// <summary> /// Binds data contexts ASAP to prevent flickering. /// </summary> public MainWindow() { InitializeComponent(); SettingsService.Upgrade(); // Network tasks Task.Run(async() => { await FlagService.CheckAllFlags(); }); Task.Run(async() => { await UpdateService.CheckForUpdates(); }); // Bind data contexts DataContext = _styleBinding; AppraisalInfo.DataContext = _infoBinding; AppraisalControls.DataContext = _controlsBinding; }
public void GetFlagsAddsBriefingNotesSentIfBriefingHasBeenSent() { var testEvent = GetTestEvent(); var options = new FlagServiceOptions(); testEvent.BriefingNotesSent = true; var expectedFlag = Flags.BriefingNotesSent; var flagService = new FlagService(Options.Create(options)); var actualFlag = flagService.GetFlags(testEvent, expectedFlag); actualFlag.Should().Contain(expectedFlag); }
private static void Main(string[] args) { CountryDBSettings countryDBSettings = new CountryDBSettings() { ConnectionString = "mongodb://127.0.0.1:27017", DatabaseName = "CountryDB" }; FlagService flagService = new FlagService(countryDBSettings); CountryService countryService = new CountryService(countryDBSettings); Stopwatch sw = new Stopwatch(); sw.Start(); var dataSeeding = new Seeding(countryService, flagService); dataSeeding.Run(); sw.Stop(); Console.WriteLine($"Load Complete : {sw.Elapsed.TotalSeconds}"); Console.ReadKey(); }
public void GetFlagsAddsNeedsEmailingToSoonEventNotRecentlyEmailed() { var testEvent = GetTestEvent(); var sendEmailThreshold = 90; var emailCautionThreshold = 45; var options = new FlagServiceOptions { SendEmailThreshold = sendEmailThreshold, EmailCautionThreshold = emailCautionThreshold }; testEvent.Date = DateTime.Today.AddDays(sendEmailThreshold - 1); testEvent.LastEmailedOut = DateTime.Today.AddDays(-(emailCautionThreshold + 1)); var expectedFlag = Flags.NeedsEmailing; var flagService = new FlagService(Options.Create(options)); var actualFlag = flagService.GetFlags(testEvent, expectedFlag); actualFlag.Should().Contain(expectedFlag); }
public SetFlagCommandProcessor(FlagService flagService , LineService lineService) : base(Keyword.SetFlag, lineService) { _flagService = flagService; _lineService = lineService; }
public IHttpActionResult Delete(int id) { ResponseModel response = FlagService.DeleteFlag(id); return(Ok(response)); }
public SeedingController(CountryService countryService, FlagService flagService) { _countryService = countryService; _flagService = flagService; _seeding = new Seeding(_countryService, _flagService); }
public IHttpActionResult Flags(int id) { ResponseModel response = FlagService.SelectFlags(id); return(Ok(response)); }
public FlagController(FlagService flagService) { _flagService = flagService; }
public Seeding(CountryService countryService, FlagService flagService) { _countryService = countryService; _flagService = flagService; }