public async Task IntegrationSaveImage() { VacationsViewModel vacationsViewModel = (onlineMode) ? FactorySingleton.Factory.Get <VacationsViewModel>() : FactorySingleton.FactoryOffline.Get <VacationsViewModel>(); List <VTSModel> vtsList = await vacationsViewModel.GetVTSList(); Assert.IsNotNull(vtsList, "Message: GetVTSList error"); VacationInfoModel vacationInfo = await vacationsViewModel.GetVacationInfo(vtsList[0].Id); Assert.IsNotNull(vacationInfo, "Message: GetVacationInfo error"); string path = Path.Combine(Directory.GetCurrentDirectory(), "person.png"); Assert.IsTrue(File.Exists(path), "Message: test image file not found in TEST project"); byte[] imageByte = File.ReadAllBytes(path); Assert.IsNotNull(imageByte, "Message: File.ReadAllBytes file in byte is NULL"); vacationsViewModel.Image = imageByte; Assert.IsNotNull(vacationsViewModel.Image, "Message: test image byte[] is Null"); Assert.IsTrue((await vacationsViewModel.UpdateOrCreateVacationInfo(vacationInfo)), "Message: error UpdateOrCreateVacationInfo"); vacationsViewModel.Image = null; VacationInfoModel vacationInfoUpdated = await vacationsViewModel.GetVacationInfo(vtsList[0].Id); Assert.IsNotNull(vacationsViewModel.Image, "Message:vacationsViewModel.Image after GetVacationInfo Is Null"); Assert.AreEqual(vacationsViewModel.Image.Length, imageByte.Length, "Message: Not equal Length Image byte[] from viewmodel and real image"); Assert.AreEqual(vacationsViewModel.Image[0], imageByte[0], "Message: Not equal first byte Image byte[] from viewmodel and real image"); vacationsViewModel.Image = null;//delete Image Assert.IsNull(vacationsViewModel.Image, "Message: test image byte[] is not Null"); Assert.IsTrue((await vacationsViewModel.UpdateOrCreateVacationInfo(vacationInfo)), "Message: error UpdateOrCreateVacationInfo"); vacationInfoUpdated = await vacationsViewModel.GetVacationInfo(vtsList[0].Id); Assert.IsNull(vacationsViewModel.Image, "Message:vacationsViewModel.Image after GetVacationInfo Is not Null"); }
public async Task IntegrationCreateVacation() { VacationsViewModel vacationsViewModel = (onlineMode) ? FactorySingleton.Factory.Get <VacationsViewModel>() : FactorySingleton.FactoryOffline.Get <VacationsViewModel>(); List <VTSModel> vtsList = await vacationsViewModel.GetVTSList(); Assert.IsNotNull(vtsList, "Message: GetVTSList error"); VacationInfoModel vacationInfo = await vacationsViewModel.GetVacationInfo(vtsList[0].Id); Assert.IsNotNull(vacationInfo, "Message: GetVacationInfo error"); var oldcount = vtsList.Count; VacationInfoModel vacationInfoNew = await vacationsViewModel.CreateDraftVacationInfo(); Assert.IsNotNull(vacationInfoNew, "Message: CreateDraftVacationInfo error"); vacationInfoNew.Type.Value = "TESTING"; await vacationsViewModel.UpdateDraftVacationInfo(vacationInfoNew); if (onlineMode) { Assert.IsTrue((await vacationsViewModel.SendDraftVacationInfo()), "Message: error SendDraftVacationInfo"); vtsList = await vacationsViewModel.GetVTSList(); Assert.AreEqual(vtsList.Count, (oldcount + 1), "Message: error after Create newcount != oldcount + 1"); VacationInfoModel vacationInfoSaved = await vacationsViewModel.GetVacationInfo(vtsList[vtsList.Count - 1].Id); Assert.IsNotNull(vacationInfoSaved, "Message: GetVacationInfo2 error"); Assert.AreEqual(vacationInfoNew.Type.Value, vacationInfoSaved.Type.Value, "Message: error vacationInfoNew not Equals Type.Value vacationInfoSaved"); } }
public async Task VacationsViewModel() { VacationsViewModel vacationsViewModel = (onlineMode) ? FactorySingleton.Factory.Get <VacationsViewModel>() : FactorySingleton.FactoryOffline.Get <VacationsViewModel>(); Assert.IsNotNull(vacationsViewModel, "Message: Get<VacationsViewModel> is NULL"); List <VTSModel> vtsList = await vacationsViewModel.GetVTSList(); Assert.IsNotNull(vtsList, "Message: GetVTSList error"); Assert.IsNotNull((await vacationsViewModel.GetVacationInfo(vtsList[0].Id)), "Message: GetVacationInfo error"); Assert.IsNull((await vacationsViewModel.GetVacationInfo(0)), "Message: GetVacationInfo error null by zero ID"); }
public async Task IntegrationUpdateVacation() { VacationsViewModel vacationsViewModel = (onlineMode) ? FactorySingleton.Factory.Get <VacationsViewModel>() : FactorySingleton.FactoryOffline.Get <VacationsViewModel>(); List <VTSModel> vtsList = await vacationsViewModel.GetVTSList(); Assert.IsNotNull(vtsList, "Message: GetVTSList error"); var oldcount = vtsList.Count; VacationInfoModel vacationInfo = await vacationsViewModel.GetVacationInfo(vtsList[0].Id); Assert.IsNotNull(vacationInfo, "Message: GetVacationInfo error"); vacationInfo.Type.Value = "updating"; Assert.IsTrue((await vacationsViewModel.UpdateOrCreateVacationInfo(vacationInfo)), "Message: error UpdateOrCreateVacationInfo"); Assert.AreEqual((await vacationsViewModel.GetVTSList()).Count, oldcount, "Message: error after Update newcount != oldcount"); VacationInfoModel vacationInfoUpdated = await vacationsViewModel.GetVacationInfo(vtsList[0].Id); Assert.AreEqual(vacationInfoUpdated.Type.Value, vacationInfo.Type.Value, "Message: error vacationInfoNew not Equals Type.Value vacationInfoSaved"); }
private async void FillData() { if (_vacationsViewModel == null) { return; } _vacationInfo = await _vacationsViewModel.GetVacationInfo(_id); if (_vacationsViewModel.IsOnlineMode && _vacationInfo == null) { bool result = await Relogin(); if (result) { _vacationInfo = await _vacationsViewModel.GetVacationInfo(_id); } } if (_vacationInfo == null) { Intent myIntent = new Intent(this, typeof(MainScreenActivity)); SetResult(Result.FirstUser, myIntent); Exit(); return; } _vacationError.Text = string.Empty; _employee.Text = _vacationInfo.Employee.FullName; _vacationType.Text = _vacationInfo.Type.Value; _approver.Text = _vacationInfo.Approver.FullName; _startDate = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.StartDate); _vacationStartDateBtn.Text = _startDate.ToString("d"); _endDate = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.EndDate); _vacationEndDateBtn.Text = _endDate.ToString("d"); _duration.Text = String.Format("{0} {1}", ConverterHelper.CalculateDuration(_startDate, _endDate), _vacationsViewModel.Localaizer.Localize("days")); if (_vacationInfo.Status.Value.Equals(VacationStatus.Approved.ToString())) { _vacationStatus.SetTextColor(Android.Graphics.Color.DarkGreen); _approved = true; _vacationStartDateBtn.Enabled = _vacationPickImageFromGallery.Enabled = _vacationImageView.Enabled = _vacationPickImageFromCamera.Enabled = _vacationEndDateBtn.Enabled = false; } else { _approved = false; if (_vacationInfo.Status.Value.Equals(VacationStatus.Rejected.ToString())) { _vacationStatus.SetTextColor(Android.Graphics.Color.DarkRed); } else { if (_vacationInfo.Status.Value.Equals(VacationStatus.Closed.ToString())) { _vacationStatus.SetTextColor(Android.Graphics.Color.Black); _approved = true; _vacationStartDateBtn.Enabled = _vacationPickImageFromGallery.Enabled = _vacationImageView.Enabled = _vacationPickImageFromCamera.Enabled = _vacationEndDateBtn.Enabled = false; } else { _vacationStatus.SetTextColor(Android.Graphics.Color.Black); } } } if (_vacationsViewModel.Image != null) { Bitmap bmp = BitmapFactory.DecodeByteArray(_vacationsViewModel.Image, 0, _vacationsViewModel.Image.Length); _vacationImageView.SetImageBitmap(bmp); } _vacationStatus.Text = _vacationInfo.Status.Value; var translate = _vacationsViewModel.Localaizer.Localize(_vacationInfo.Status.Value); if (!translate.Equals("N/A")) { _vacationStatus.Text = translate; } _labelEmployee.Text = _vacationsViewModel.Employee; _lavelVacationType.Text = _vacationsViewModel.VacationType; _labelApprover.Text = _vacationsViewModel.Approver; _labelDuration.Text = _vacationsViewModel.Duration; _labelVacationStatus.Text = _vacationsViewModel.Status; _labelAttachments.Text = _vacationsViewModel.Attachments; _vacationPickImageFromGallery.Text = _vacationsViewModel.Gallery; _vacationPickImageFromCamera.Text = _vacationsViewModel.Camera; }
protected async void InintAndLocalizeControl() { if (_vacationsViewModel == null) { GoToLoginScreen(); return; } _vacationInfo = await _vacationsViewModel.GetVacationInfo(ID); if (_vacationInfo == null && _vacationsViewModel.State == UserState.Unauthorized) { GoToLoginScreen(); return; } _vacationError.Text = string.Empty; _employee.Text = _vacationInfo.Employee.FullName; _vacationType.Text = _vacationInfo.Type.Value; _approver.Text = _vacationInfo.Approver.FullName; _startDate = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.StartDate).Date; //_vacationStartDateBtn.MinimumDate = (NSDate)DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); _vacationStartDateBtn.SetDate((NSDate)_startDate.Date.AddHours(2), true); _endDate = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.EndDate).Date; //_vacationEndDateBtn.MinimumDate = (NSDate)DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); _vacationEndDateBtn.SetDate((NSDate)_endDate.Date.AddHours(2), true); _duration.Text = string.Format("{0} {1}", ConverterHelper.CalculateDuration(_startDate, _endDate), Localize("days")); if (_vacationInfo.Status.Value.Equals(VacationStatus.Approved.ToString())) { _approved = true; _vacationStatus.TextColor = UIColor.Green; _vacationStartDateBtn.Enabled = _vacationPickImageFromGallery.Enabled = _vacationPickImageFromCamera.Enabled = _vacationEndDateBtn.Enabled = false; } else { _approved = false; if (_vacationInfo.Status.Value.Equals(VacationStatus.Rejected.ToString())) { _vacationStatus.TextColor = UIColor.Red; } else { if (_vacationInfo.Status.Value.Equals(VacationStatus.Closed.ToString())) { _vacationStatus.TextColor = UIColor.Black; } else { _vacationStatus.TextColor = UIColor.Black; } } } if (_vacationsViewModel.Image != null) { UIImage img = ImageConverter.ToImage(_vacationsViewModel.Image); if (img != null) { _vacationImage.Image = img; } } _vacationStatus.Text = _vacationInfo.Status.Value; var translate = Localize(_vacationInfo.Status.Value); if (!translate.Equals("N/A")) { _vacationStatus.Text = translate; } _labelEmployee.Text = _vacationsViewModel.Employee; _labelVacationType.Text = _vacationsViewModel.VacationType; _labelApprover.Text = _vacationsViewModel.Approver; _labelDuration.Text = _vacationsViewModel.Duration; _labelVacationStatus.Text = _vacationsViewModel.Status; _labelAttachments.Text = _vacationsViewModel.Attachments; _vacationPickImageFromGallery.SetTitle(_vacationsViewModel.Gallery, UIControlState.Normal); _vacationPickImageFromCamera.SetTitle(_vacationsViewModel.Camera, UIControlState.Normal); }