Exemplo n.º 1
0
Arquivo: Test.cs Projeto: 5509850/vts
        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");
        }
Exemplo n.º 2
0
        private async Task <bool> Save()
        {
            bool result = false;

            if (_approved)
            {
                _vacationError.Text = _vacationsViewModel.Localaizer.Localize("dateApproved");
                AlertDialog(_vacationsViewModel.Localaizer.Localize("dateApproved"), null);
                return(false);
            }
            if (_startDate > _endDate)
            {
                _vacationError.Text = _vacationsViewModel.Localaizer.Localize("dateError");
                AlertDialog(_vacationsViewModel.Localaizer.Localize("dateError"), null);
                return(false);
            }
            else
            {
                _vacationError.Text     = string.Empty;
                _vacationInfo.StartDate = (long)(_startDate - new DateTime(1970, 1, 1)).TotalMilliseconds;
                _vacationInfo.EndDate   = (long)(_endDate - new DateTime(1970, 1, 1)).TotalMilliseconds;

                if (_imageUri != null)
                {
                    _vacationsViewModel.Image = Utils.GetByteByURI(this.ApplicationContext, _imageUri);
                }
                try
                {
                    if (_vacationInfo != null)
                    {
                        ShowProgress(_vacationsViewModel.Localaizer.Localize("sending"));
                        await Task.Delay(500);

                        result = await _vacationsViewModel.UpdateOrCreateVacationInfo(_vacationInfo);

                        HideProgress();
                    }
                }
                catch (Exception ex)
                {
                    _vacationError.Text = ex.Message;
                    HideProgress();
                    return(false);
                }
                Intent myIntent = new Intent(this, typeof(MainScreenActivity));
                SetResult(Result.Ok, myIntent);
                Exit();
            }
            return(true);
        }
Exemplo n.º 3
0
Arquivo: Test.cs Projeto: 5509850/vts
        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");
        }
Exemplo n.º 4
0
        protected async Task <bool> Save()
        {
            bool result = false;

            if (_approved)
            {
                _vacationError.Text = Localize("dateApproved");
                Allert(_vacationError.Text);
                return(false);
            }
            if (_startDate > _endDate)
            {
                _vacationError.Text = Localize("dateError");
                Allert(_vacationError.Text);
                return(false);
            }
            else
            {
                _vacationError.Text     = string.Empty;
                _vacationInfo.StartDate = ConverterHelper.ConvertDateTimeToMillisec(_startDate);
                _vacationInfo.EndDate   = ConverterHelper.ConvertDateTimeToMillisec(_endDate);

                if (_tempImg != null)
                {
                    _vacationsViewModel.Image = _tempImg;
                }
                try
                {
                    if (_vacationInfo != null)
                    {
                        _vacationError.Text        = Localize("sending");
                        _vacationInfo.Status.Value = VacationStatus.WaitingForApproval.ToString();
                        result = await _vacationsViewModel.UpdateOrCreateVacationInfo(_vacationInfo);
                    }
                }
                catch (Exception ex)
                {
                    _vacationError.Text = ex.Message;
                    return(false);
                }
                GoToVacationScreen();
            }
            return(true);
        }