Exemple #1
0
        public async Task TestSQLServiceSaveImage()
        {
            await InitData();

            string path = Path.Combine(Directory.GetCurrentDirectory(), "person.png");

            byte[] image = File.ReadAllBytes(path);
            //get
            VacationsDataService _vacationsDataService = FactorySingleton.FactoryOffline.Get <VacationsDataService>();
            VacationInfoModel    _vacationInfoModel    = await _vacationsDataService.GetVacationByIdFromSql(id);

            Assert.IsNotNull(_vacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            Assert.IsNull(_vacationInfoModel.VacationForm, "Message: vacationInfoModel.VacationForm IS NOT NULL before saving");
            Assert.IsNotNull(image, "Error: image byte[] Is Null");
            //save
            _vacationInfoModel.VacationForm = image;
            await _vacationsDataService.UpdateOrCreateVacationsSql(_vacationInfoModel);

            VacationInfoModel _updatedVacationInfoModel = await _vacationsDataService.GetVacationByIdFromSql(id);

            Assert.IsNotNull(_updatedVacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            Assert.IsNotNull(_updatedVacationInfoModel.VacationForm, "Error: VacationForm Is Null");
            byte[] savedimage = JsonConvertorExtention.FromJsonString <byte[]>(_updatedVacationInfoModel.VacationForm.ToJsonString());
            Assert.IsNotNull(savedimage, "Error: savedimage byte[] Is Null");
            Assert.AreEqual(image[0], savedimage[0], "Message: image byte[0] NOT Equal after save");
            Assert.AreEqual(image.Length, savedimage.Length, "Message: image byte.length NOT Equal after save");
            //delete
            _vacationInfoModel.VacationForm = null;
            await _vacationsDataService.UpdateOrCreateVacationsSql(_vacationInfoModel);

            _updatedVacationInfoModel = await _vacationsDataService.GetVacationByIdFromSql(id);

            Assert.IsNotNull(_updatedVacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            Assert.IsNull(_updatedVacationInfoModel.VacationForm, "Error: VacationForm Is Not Null after delete");
        }
Exemple #2
0
        public async Task TestSQLServiceCreateVacation()
        {
            await InitData();

            VacationsDataService _vacationsDataService = FactorySingleton.FactoryOffline.Get <VacationsDataService>();
            VacationInfoModel    _vacationInfoModel    = await _vacationsDataService.GetVacationByIdFromSql(0);

            Assert.IsNull(_vacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() ZERO ID Is not Null");
            _vacationInfoModel = await _vacationsDataService.GetVacationByIdFromSql(id);

            Assert.IsNotNull(_vacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            _vacationInfoModel.Id           = 0;
            _vacationInfoModel.Status.Value = "new";
            await _vacationsDataService.UpdateOrCreateVacationsSql(_vacationInfoModel);

            VacationInfoModel _newVacationInfoModel = await _vacationsDataService.GetVacationByIdFromSql(0);

            Assert.IsNotNull(_newVacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() ZERO ID Is Null");
            Assert.AreEqual(_vacationInfoModel.Id, _newVacationInfoModel.Id, "Error: Id not equal");
            Assert.AreEqual(_vacationInfoModel.Status.Value, _newVacationInfoModel.Status.Value, "Error: value not equal");
            await _vacationsDataService.DeleteVacationsInfoInSqlById(0);

            _vacationInfoModel = await _vacationsDataService.GetVacationByIdFromSql(0);

            Assert.IsNull(_vacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() ZERO ID Is not Null");
        }
Exemple #3
0
        public async Task TestSQLServiceUpdateVacationById()
        {
            await InitData();

            VacationsDataService _vacationsDataService = FactorySingleton.FactoryOffline.Get <VacationsDataService>();
            VacationInfoModel    _vacationInfoModel    = await _vacationsDataService.GetVacationByIdFromSql(id);

            Assert.IsNotNull(_vacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            _vacationInfoModel.Status.Value = "sqltest";
            VacationInfoModel _notUpdatedVacationInfoModel = await _vacationsDataService.GetVacationByIdFromSql(id);

            Assert.IsNotNull(_notUpdatedVacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            Assert.AreNotEqual(_notUpdatedVacationInfoModel.Status.Value, _vacationInfoModel.Status.Value, "Error: _notUpdatedVacationInfoModel == _vacationInfoModel (changed field)");
            await _vacationsDataService.UpdateOrCreateVacationsSql(_vacationInfoModel);

            VacationInfoModel _updatedVacationInfoModel = await _vacationsDataService.GetVacationByIdFromSql(id);

            Assert.IsNotNull(_updatedVacationInfoModel, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            Assert.AreEqual(_vacationInfoModel.Status.Value, _updatedVacationInfoModel.Status.Value, "Error: _vacationInfoModel != _updatedVacationInfoModel");
        }