Esempio n. 1
0
File: Test.cs Progetto: 5509850/vts
        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");
            }
        }
Esempio n. 2
0
File: Test.cs Progetto: 5509850/vts
        public async Task IntegrationDeleteVacation()
        {
            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;

            Assert.IsTrue(await vacationsViewModel.DeleteVacationInfo(vtsList[vtsList.Count - 1]), "Message: error DeleteVacationInfo");
            Assert.AreNotEqual((await vacationsViewModel.GetVTSList()).Count, oldcount, "Message: error after Delete newcount == oldcount");
        }
Esempio n. 3
0
 protected override void FetchDataToControl()
 {
     try
     {
         _vacationsViewModel = FactorySingleton.Factory.Get <VacationsViewModel>();
         Task <List <VTSModel> > task = Task.Run(async() => await _vacationsViewModel.GetVTSList());
         task.Wait();
         _listVTSModel = task.Result;
         if (_listVTSModel == null && _vacationsViewModel.State == UserState.Unauthorized)
         {
             GoToLoginScreen();
             return;
         }
         tableSource  = new TableSource(_listVTSModel, this);
         table.Source = tableSource;
         _butnAdd     = new UIBarButtonItem(UIBarButtonSystemItem.Add, ButnAddClicked);
         NavigationItem.RightBarButtonItem = _butnAdd;
         _butnMenu       = new  UIBarButtonItem();
         _butnMenu.Title = Localize("Menu");
         NavigationItem.LeftBarButtonItem = _butnMenu;
         NavigationItem.Title             = Localize("Requests");
     }
     catch (Exception)
     {
     }
 }
Esempio n. 4
0
File: Test.cs Progetto: 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");
        }
Esempio n. 5
0
File: Test.cs Progetto: 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");
        }
Esempio n. 6
0
File: Test.cs Progetto: 5509850/vts
        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");
        }
Esempio n. 7
0
 private void LoadListView()
 {
     try
     {
         Task <List <VTSModel> > task = Task.Run(async() => await _vacationsViewModel.GetVTSList());
         task.Wait();
         _listVTSModel     = task.Result;
         _listAdapter      = new VTSListAdapter(this, _listVTSModel);
         _listView.Adapter = _listAdapter;
     }
     catch (Exception ex)
     {
         Toast.MakeText(this, ex.Message, ToastLength.Short);
     }
 }