public void Setup() { _geolocator = CrossGeolocator.Geolocator = Substitute.For <IGeolocator>(); _permissionValidator = Substitute.For <IPermissionValidator>(); _messagingHandler = Substitute.For <IMessagingHandler>(); _trackerService = new TrackerService(_permissionValidator, _messagingHandler); }
public IHttpActionResult Index([FromBody] IdentifyViewModel vm) { ITrackerService service = new TrackerService(); service.IdentifyContact(vm.PersonId); var response = new ProfileViewModel(contactProfileProvider); var name = contactProfileProvider.PersonalInfo.FirstName; Guid guid; // if name is empty, unkown or it has a guid, treat it as "no name". The client should trigger the update name action if (string.IsNullOrEmpty(name) || string.Compare(name, "unknown", true, CultureInfo.CurrentCulture) == 0 || Guid.TryParse(name, out guid)) { response.Name = string.Empty; } else { response.Name = name; } return(new JsonResult <ProfileViewModel>(response, new JsonSerializerSettings(), Encoding.UTF8, this)); }
public App() { InitializeComponent(); MainPage = new LandingPage(); TrackerService.Init(GestureType.All, true); }
public void TrackOutcome_NullOutcomeId_ThrowException([NoAutoProperties] TrackerService trackerService, ITracker tracker) { tracker.IsActive.Returns(true); using (new TrackerSwitcher(tracker)) { trackerService.Invoking(x => x.TrackOutcome(null)).ShouldThrow <ArgumentNullException>(); } }
public void SetUp() { _fixture = new Fixture(); _userId = Guid.NewGuid(); _someonesId = Guid.NewGuid(); _mockTrackerRepository = new RepositoryMock <Tracker>(); _mockEventRepository = new RepositoryMock <Event>(); _trackerService = new TrackerService(_mockTrackerRepository); }
public ControlController( TrackerService trackerService, MessagerService messagerService, ApplicationDbContext dbContext) { _trackerService = trackerService; _messagerService = messagerService; _dbContext = dbContext; }
public PingModule( ILogger <PingModule> logger, MessagingService messagingService, TrackerService trackerService) { _logger = logger; _messagingService = messagingService; _trackerService = trackerService; }
private void OnEditRecord(TrackedDayRecordViewModel recordViewModel) { var context = (UserViewModel)BindingContext; TrackerService.EditRecord(Mapper.Map <TrackedDayRecordModel>(recordViewModel), context.SelectedDate); var newContext = Mapper.Map <UserViewModel>(App.User); newContext.SelectedDate = context.SelectedDate; BindingContext = newContext; }
private void RemoveRecord(int id) { var context = (UserViewModel)BindingContext; TrackerService.RemoveRecord(id, context.SelectedDate); var newContext = Mapper.Map <UserViewModel>(App.User); newContext.SelectedDate = context.SelectedDate; BindingContext = newContext; }
public void IdentifyContact_ValidIdentifier_ShouldIdentifyContact([NoAutoProperties] TrackerService trackerService, string contactIdentifier, ITracker tracker, [Substitute] Session session) { tracker.IsActive.Returns(true); tracker.Session.Returns(session); using (new TrackerSwitcher(tracker)) { trackerService.IdentifyContact(contactIdentifier); tracker.Session.Received().Identify(contactIdentifier); } }
public ChatController( ApplicationDbContext dbContext, IConfiguration configuration, TrackerService trackerService, MessagerService messagerService) { _dbContext = dbContext; _configuration = configuration; _trackerService = trackerService; _messagerService = messagerService; }
private void OnAddRecord(TrackedDayRecordViewModel recordViewModel) { TrackerService.AddRecordToday(Mapper.Map <TrackedDayRecordModel>(recordViewModel)); // add to view model var user = (UserViewModel)BindingContext; var trackedToday = user.TrackedToday(); trackedToday.Records.Add(recordViewModel); BindingContext = Mapper.Map <UserViewModel>(App.User); }
public override void Cleanup() { VisualizationService.Stop(); TrackerService.Destroy(); CameraService.Destroy(); Messenger.Default.Send(new RemoveCameraMessage(Camera)); // todo remove after message with feedback? SimpleIoc.Default.Unregister<CameraViewModel>(Camera.GUID); base.Cleanup(); }
public async Task TryAddTrackerAsync_NameOnly_HasId() { // arrange var service = new TrackerService(_database, _logger); string name = "Test"; // act var tracker = await service.TryAddTrackerAsync(name); // assert Assert.NotEqual(default, tracker.Id);
public void DoToggleAnnotate(bool annotate) { Camera.Annotate = annotate; ConsoleService.Write("Annotate: " + annotate); // reload image if (Camera.Design) { TrackerService.Start(); } }
public TrackedDayModel TrackedDay(DateTime date) { var result = TrackedDays.FirstOrDefault(trackedDay => trackedDay.Date.ToString("d") == date.ToString("d")); if (result == null) { result = TrackerService.AddTrackedDay(App.User.Goal, date); } return(result); }
public async Task TryAddTrackerAsync_DuplicateName_ReturnsNull() { // arrange var service = new TrackerService(_database, _logger); string name = "T0"; // created in seed // act var tracker = await service.TryAddTrackerAsync(name); // assert Assert.Null(tracker); }
public async Task TryAddTrackerAsync_NullName_ReturnsNull() { // arrange var service = new TrackerService(_database, _logger); string name = null; // act var tracker = await service.TryAddTrackerAsync(name); // assert Assert.Null(tracker); }
private void EditRecord(int id) { var context = (UserViewModel)BindingContext; var record = Mapper.Map <TrackedDayRecordViewModel>(TrackerService.GetRecord(id, context.SelectedDate)); record.DrinkType = record.DrinkTypes.First(drinkType => drinkType.Name == record.DrinkType.Name); var popup = new AddTrackerRecordPopup() { BindingContext = record }; popup.OnAddRecord += OnEditRecord; PopupNavigation.Instance.PushAsync(popup); }
private void BtnStartTracking_Click(object sender, EventArgs e) { HttpClient client = new HttpClient(); string url = ConfigurationManager.AppSettings["ISSApiURL"]; ITrackerService trackerService = new TrackerService(client, url); IMapService mapService = new MapService(); IAPIMapperService converter = new APIMapperService(); IDistanceService distanceService = new DistanceService(); ISpeedService speedService = new SpeedService(); MapForm map = new MapForm(trackerService, mapService, converter, distanceService, speedService); map.Show(); }
static void Main(string[] args) { TrackerService trackerLogic = new TrackerService(); Stopwatch clock = new Stopwatch(); clock.Start(); projectService.CreateProject("Poneslas"); trackerService.ReadTracker(); trackerService.UpdateTracker(2, "Process", "Rabota", 2); trackerService.DeleteTracker(2, "Process", "Rabota", 2); developerService.ZaprosProjectTracker(); customerService.ZaprosCustomerProject(); clock.Stop(); Console.WriteLine(clock.ElapsedMilliseconds); Insert(); }
public override bool OnStartJob(JobParameters args) { _ = Task.Run(async() => { Log.Debug("LOCTEST", "LOCTEST - OnStartJob - 1"); var folder = Android.OS.Environment.ExternalStorageDirectory.ToString(); var ts = new TrackerService(folder); await ts.TrackAsync("LS"); Log.Debug("LOCTEST", "LOCTEST - OnStartJob - 2"); JobFinished(args, false); }); return(true); }
public async Task TestDeserializationFailure() { //Arrange string fakeURL = "http://fakeURL"; var handlerMock = mockHandler(fakeOKResponseWithWrongJSON()); var httpClient = new HttpClient(handlerMock); ITrackerService trackerService = new TrackerService(httpClient, fakeURL); //Act Func <Task> action = async() => await trackerService.GetISSCurrentPosition(); //Assert action.Should() .Throw <Exception>() .WithMessage("Error calling ISS API"); }
public async Task <ActionResult <Tracker?> > Create(CreateTrackerRequest request) { try { Tracker tracker = await TrackerService .CreateTracker(request.ChannelId, request.GameId) .ConfigureAwait(false); return(Created($"api/trackers/{tracker.Id}", tracker)); } catch (InvalidOperationException ex) { return(Problem(ex.Message, statusCode: (int)HttpStatusCode.Conflict)); } catch (ArgumentException ex) { return(Problem(ex.Message, statusCode: (int)HttpStatusCode.BadRequest)); } }
public async Task <ActionResult <Tracker?> > UpdateTracker(UpdateTrackerRequest request, long id) { try { Tracker tracker = await TrackerService .UpdateTracker(id, request.GameId, request.ChannelId) .ConfigureAwait(false); return(Ok(tracker)); } catch (InvalidOperationException ex) { return(Problem(ex.Message, statusCode: (int)HttpStatusCode.Conflict)); } catch (ArgumentException ex) { return(Problem(ex.Message, statusCode: (int)HttpStatusCode.BadRequest)); } }
public void DoToggleTracking(bool enabled) { if (enabled) { if (CameraService.Enabled) { CameraService.Stop(); } Camera.Tracking = TrackerService.Start(); } else { Camera.Tracking = TrackerService.Stop(); if (Camera.ShowImage) { CameraService.Start(); } } ConsoleService.Write("Tracking: " + enabled); }
public async Task TestGetISSCurrentPositionOkResult() { //Arrange string fakeURL = "http://fakeURL"; var handlerMock = mockHandler(fakeOKResponse()); var httpClient = new HttpClient(handlerMock); ITrackerService trackerService = new TrackerService(httpClient, fakeURL); //Act var apiResult = await trackerService.GetISSCurrentPosition(); //Assert apiResult.Should().BeOfType <IssApiResponse>().And.NotBeNull(); apiResult.timestamp.Should().Be(1600000000); apiResult.iss_position.Should().NotBeNull(); apiResult.iss_position.latitude.Should().Be("45.0"); apiResult.iss_position.longitude.Should().Be("13.0"); }
public async Task TestNotSuccessStatusCode() { //Arrange string fakeURL = "http://fakeURL"; var handlerMock = mockHandler(fakeKOResponse()); var httpClient = new HttpClient(handlerMock); ITrackerService trackerService = new TrackerService(httpClient, fakeURL); //Act Func <Task> action = async() => await trackerService.GetISSCurrentPosition(); //Assert action.Should() .Throw <Exception>() .WithMessage("Error calling ISS API") .WithInnerException <Exception>() .WithMessage("ISS API respond with a status error code of*"); }
public async Task TestEmptyResponse() { //Arrange string fakeURL = "http://fakeURL"; var handlerMock = mockHandler(fakeOKResponseWithEmptyContent()); var httpClient = new HttpClient(handlerMock); ITrackerService trackerService = new TrackerService(httpClient, fakeURL); //Act Func <Task> action = async() => await trackerService.GetISSCurrentPosition(); //Assert action.Should() .Throw <Exception>() .WithMessage("Error calling ISS API") .WithInnerException <Exception>() .WithMessage("Content response is Empty"); }
public override Result DoWork() { try { Log.Info("LOCTEST", "LOCTEST - DoWork"); Task.Run(async() => { var folder = Android.OS.Environment.ExternalStorageDirectory.ToString(); var ts = new TrackerService(folder); await ts.TrackAsync("LW"); }) .Wait(); return(Result.InvokeSuccess()); } catch (Exception ex) { Log.Error("LOCTEST", $"LOCTEST - {ex.Message}"); return(Result.InvokeRetry()); } }