public async Task <field_values> CreateFieldValue(cases aCase, check_lists checkList, fields f, int?ud_id, int?userId, string value, int?version, workers worker)
        {
            field_values fv = new field_values();

            fv.CaseId      = aCase.Id;
            fv.CheckList   = checkList;
            fv.CheckListId = checkList.Id;
            fv.CreatedAt   = DateTime.UtcNow;
            fv.Date        = DateTime.Now;
            fv.DoneAt      = DateTime.Now;
            fv.Field       = f;
            fv.FieldId     = f.Id;
            fv.UpdatedAt   = DateTime.UtcNow;
            if (ud_id != null)
            {
                fv.UploadedDataId = ud_id;
            }
            fv.WorkerId      = userId;
            fv.Value         = value;
            fv.Version       = version;
            fv.Worker        = worker;
            fv.WorkflowState = Constants.WorkflowStates.Created;

            dbContext.field_values.Add(fv);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(fv);
        }
        public async Task <cases> CreateCase(string caseUId, check_lists checkList, DateTime created_at, string custom, DateTime done_at, workers doneByUserId, int microtingCheckId, int microtingUId, sites site, int?status, string caseType, units unit, DateTime updated_at, int version, workers worker, string WorkFlowState)
        {
            cases aCase = new cases();

            aCase.CaseUid           = caseUId;
            aCase.CheckList         = checkList;
            aCase.CheckListId       = checkList.Id;
            aCase.CreatedAt         = created_at;
            aCase.Custom            = custom;
            aCase.DoneAt            = done_at;
            aCase.WorkerId          = worker.Id;
            aCase.MicrotingCheckUid = microtingCheckId;
            aCase.MicrotingUid      = microtingUId;
            aCase.Site          = site;
            aCase.SiteId        = site.Id;
            aCase.Status        = status;
            aCase.Type          = caseType;
            aCase.Unit          = unit;
            aCase.UnitId        = unit.Id;
            aCase.UpdatedAt     = updated_at;
            aCase.Version       = version;
            aCase.Worker        = worker;
            aCase.WorkflowState = WorkFlowState;
            dbContext.cases.Add(aCase);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(aCase);
        }
Exemple #3
0
        public field_values CreateFieldValue(cases aCase, check_lists checkList, fields f, int?ud_id, int?userId, string value, int?version, workers worker)
        {
            field_values fv = new field_values();

            fv.case_id       = aCase.id;
            fv.check_list    = checkList;
            fv.check_list_id = checkList.id;
            fv.created_at    = DateTime.Now;
            fv.date          = DateTime.Now;
            fv.done_at       = DateTime.Now;
            fv.field         = f;
            fv.field_id      = f.id;
            fv.updated_at    = DateTime.Now;
            if (ud_id != null)
            {
                fv.uploaded_data_id = ud_id;
            }
            fv.user_id        = userId;
            fv.value          = value;
            fv.version        = version;
            fv.worker         = worker;
            fv.workflow_state = Constants.WorkflowStates.Created;

            DbContext.field_values.Add(fv);
            DbContext.SaveChanges();
            return(fv);
        }
Exemple #4
0
        public async Task SQL_Case_CheckListSitesRead_DoesSiteRead()
        {
            Random rnd   = new Random();
            sites  site1 = await testHelpers.CreateSite("mySite2", 331);

            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template2", "template_desc", "", "", 1, 1);

            string guid          = Guid.NewGuid().ToString();
            string guid2         = Guid.NewGuid().ToString();
            int    lastCheckUid1 = rnd.Next(1, 255);
            int    lastCheckUid2 = rnd.Next(1, 255);

            check_list_sites cls1 = await testHelpers.CreateCheckListSite(cl1, cl1_Ca, site1, cl1_Ua, 1, Constants.WorkflowStates.Created, lastCheckUid1);

            check_list_sites cls2 = await testHelpers.CreateCheckListSite(cl1, cl1_Ca, site1, cl1_Ua, 2, Constants.WorkflowStates.Created, lastCheckUid2);

            // Act
            List <int> matches = await sut.CheckListSitesRead(cl1.Id, (int)site1.MicrotingUid, Constants.WorkflowStates.NotRemoved);

            List <int> matches2 = await sut.CheckListSitesRead(cl1.Id, (int)site1.MicrotingUid, null);

            List <check_list_sites> checkListSiteResult1 = dbContext.check_list_sites.AsNoTracking().ToList();
            var versionedMatches1 = dbContext.check_list_site_versions.AsNoTracking().ToList();


            // Assert
            Assert.NotNull(matches);
            Assert.AreEqual(2, matches.Count);
            Assert.AreEqual(2, matches2.Count);
            Assert.AreEqual(cls1.MicrotingUid, matches[0]);
            Assert.AreEqual(cls1.MicrotingUid, matches2[0]);
            Assert.AreEqual(cls2.MicrotingUid, matches2[1]);
        }
Exemple #5
0
        public void SQL_Case_CheckListSitesRead_DoesSiteRead()
        {
            sites       site1  = testHelpers.CreateSite("mySite2", 331);
            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template2", "template_desc", "", "", 1, 1);

            string guid          = Guid.NewGuid().ToString();
            string guid2         = Guid.NewGuid().ToString();
            string lastCheckUid1 = Guid.NewGuid().ToString();
            string lastCheckUid2 = Guid.NewGuid().ToString();

            check_list_sites cls1 = testHelpers.CreateCheckListSite(cl1, cl1_Ca, site1, cl1_Ua, 1, Constants.WorkflowStates.Created, lastCheckUid1);
            check_list_sites cls2 = testHelpers.CreateCheckListSite(cl1, cl1_Ca, site1, cl1_Ua, 2, Constants.WorkflowStates.Created, lastCheckUid2);

            // Act
            List <string>           matches              = sut.CheckListSitesRead(cl1.id, (int)site1.microting_uid, Constants.WorkflowStates.NotRemoved);
            List <string>           matches2             = sut.CheckListSitesRead(cl1.id, (int)site1.microting_uid, null);
            List <check_list_sites> checkListSiteResult1 = DbContext.check_list_sites.AsNoTracking().ToList();
            var versionedMatches1 = DbContext.check_list_site_versions.AsNoTracking().ToList();


            // Assert
            Assert.NotNull(matches);
            Assert.AreEqual(2, matches.Count);
            Assert.AreEqual(2, matches2.Count);
            Assert.AreEqual(cls1.microting_uid, matches[0]);
            Assert.AreEqual(cls1.microting_uid, matches2[0]);
            Assert.AreEqual(cls2.microting_uid, matches2[1]);
        }
        public void SQL_Case_CaseDeleteResult_DoesMarkCaseRemoved()
        {
            // Arrance
            sites site = new sites();

            site.name = "SiteName";
            DbContext.sites.Add(site);
            DbContext.SaveChanges();

            check_lists cl = new check_lists();

            cl.label = "label";

            DbContext.check_lists.Add(cl);
            DbContext.SaveChanges();

            cases aCase = new cases();

            aCase.microting_uid       = "microting_uid";
            aCase.microting_check_uid = "microting_check_uid";
            aCase.workflow_state      = Constants.WorkflowStates.Created;
            aCase.check_list_id       = cl.id;
            aCase.site_id             = site.id;

            DbContext.cases.Add(aCase);
            DbContext.SaveChanges();

            // Act
            sut.CaseDeleteResult(aCase.id);
            cases theCase = sut.CaseReadFull(aCase.microting_uid, aCase.microting_check_uid);

            // Assert
            Assert.NotNull(theCase);
            Assert.AreEqual(Constants.WorkflowStates.Removed, theCase.workflow_state);
        }
Exemple #7
0
        public cases CreateCase(string caseUId, check_lists checkList, DateTime created_at, string custom, DateTime done_at, workers doneByUserId, string microtingCheckId, string microtingUId, sites site, int?status, string caseType, units unit, DateTime updated_at, int version, workers worker, string WorkFlowState)
        {
            cases aCase = new cases();

            aCase.case_uid            = caseUId;
            aCase.check_list          = checkList;
            aCase.check_list_id       = checkList.id;
            aCase.created_at          = created_at;
            aCase.custom              = custom;
            aCase.done_at             = done_at;
            aCase.done_by_user_id     = worker.id;
            aCase.microting_check_uid = microtingCheckId;
            aCase.microting_uid       = microtingUId;
            aCase.site           = site;
            aCase.site_id        = site.id;
            aCase.status         = status;
            aCase.type           = caseType;
            aCase.unit           = unit;
            aCase.unit_id        = unit.id;
            aCase.updated_at     = updated_at;
            aCase.version        = version;
            aCase.worker         = worker;
            aCase.workflow_state = WorkFlowState;
            DbContext.cases.Add(aCase);
            DbContext.SaveChanges();

            return(aCase);
        }
Exemple #8
0
        public async Task SQL_Case_CaseDeleteReversed_DoesDeletionReversed()
        {
            // Arrance
            Random rnd  = new Random();
            sites  site = await testHelpers.CreateSite("mySite", 987);

            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "bla", "bla_desc", "", "", 0, 0);

            string guid          = Guid.NewGuid().ToString();
            int    lastCheckUid1 = rnd.Next(1, 255);


            check_list_sites cls1 = await testHelpers.CreateCheckListSite(cl1, cl1_Ca, site, cl1_Ua, 1, Constants.WorkflowStates.Created, lastCheckUid1);

            // Act
            await sut.CaseDeleteReversed(cls1.MicrotingUid);

            List <check_list_sites> checkListSiteResult = dbContext.check_list_sites.AsNoTracking().ToList();

            // Assert

            Assert.NotNull(checkListSiteResult);
            Assert.AreEqual(1, checkListSiteResult.Count);
            Assert.AreEqual(Constants.WorkflowStates.Removed, checkListSiteResult[0].WorkflowState);
        }
        public void Core_Template_TemplateRead_ReturnsTemplateWithQuickSync()
        {
            //Arrance
            #region Tempalte

            DateTime    cl1_ca = DateTime.Now;
            DateTime    cl1_ua = DateTime.Now;
            check_lists cl1    = testHelpers.CreateTemplate(cl1_ca, cl1_ua, "A", "D", "CheckList", "Template1FolderName", 1, 1);
            //cl1.quick_sync_enabled = 1;
            check_lists cl_ud = DbContext.check_lists.Single(x => x.id == cl1.id);
            //DbContext.check_lists.Add(cl1);
            cl_ud.quick_sync_enabled = 1;
            DbContext.SaveChanges();

            #endregion

            //Act
            MainElement match = sut.TemplateRead(cl1.id);

            //Assert
            Assert.NotNull(match);
            Assert.AreEqual(match.Id, cl1.id);
            Assert.AreEqual(match.CaseType, cl1.case_type);
            Assert.AreEqual(match.FastNavigation, false);
            Assert.AreEqual(match.Label, cl1.label);
            Assert.AreEqual(match.ManualSync, false);
            Assert.AreEqual(match.MultiApproval, false);
            Assert.AreEqual(match.Repeated, cl1.repeated);
            Assert.AreEqual(match.EnableQuickSync, true);
        }
        public async Task SQL_File_FileCaseFindMUId_doesFindMUId()
        {
            Random rnd   = new Random();
            sites  site1 = await testHelpers.CreateSite("MySite", 22);

            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template1", "template_desc", "", "", 1, 1);

            string guid = Guid.NewGuid().ToString();


            DateTime c1_ca  = DateTime.Now.AddDays(-9);
            DateTime c1_da  = DateTime.Now.AddDays(-8).AddHours(-12);
            DateTime c1_ua  = DateTime.Now.AddDays(-8);
            workers  worker = await testHelpers.CreateWorker("*****@*****.**", "Arne", "Jensen", 21);

            site_workers site_workers = await testHelpers.CreateSiteWorker(55, site1, worker);

            units unit = await testHelpers.CreateUnit(48, 49, site1, 348);

            string microtingUId     = Guid.NewGuid().ToString();
            string microtingCheckId = Guid.NewGuid().ToString();
            cases  aCase1           = await testHelpers.CreateCase("case1UId", cl1, c1_ca, "custom1",
                                                                   c1_da, worker, rnd.Next(1, 255), rnd.Next(1, 255),
                                                                   site1, 1, "caseType1", unit, c1_ua, 1, worker, Constants.WorkflowStates.Created);

            uploaded_data ud = new uploaded_data
            {
                Checksum     = "checksum1",
                Extension    = "extension",
                CurrentFile  = "currentFile1",
                UploaderId   = 223,
                UploaderType = "uploader_type",
                FileLocation = "url",
                FileName     = "fileName"
            };

            dbContext.uploaded_data.Add(ud);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            field_values fVs = new field_values
            {
                UploadedDataId = ud.Id,
                CaseId         = aCase1.Id
            };

            dbContext.field_values.Add(fVs);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);


            // Act
            await sut.FileCaseFindMUId("url");


            Assert.NotNull(fVs);
            Assert.AreEqual(fVs.CaseId, aCase1.Id);
        }
Exemple #11
0
        public void SQL_File_FileCaseFindMUId_doesFindMUId()
        {
            sites       site1  = testHelpers.CreateSite("MySite", 22);
            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template1", "template_desc", "", "", 1, 1);

            string guid = Guid.NewGuid().ToString();


            DateTime     c1_ca        = DateTime.Now.AddDays(-9);
            DateTime     c1_da        = DateTime.Now.AddDays(-8).AddHours(-12);
            DateTime     c1_ua        = DateTime.Now.AddDays(-8);
            workers      worker       = testHelpers.CreateWorker("*****@*****.**", "Arne", "Jensen", 21);
            site_workers site_workers = testHelpers.CreateSiteWorker(55, site1, worker);
            units        unit         = testHelpers.CreateUnit(48, 49, site1, 348);

            string microtingUId     = Guid.NewGuid().ToString();
            string microtingCheckId = Guid.NewGuid().ToString();
            cases  aCase1           = testHelpers.CreateCase("case1UId", cl1, c1_ca, "custom1",
                                                             c1_da, worker, "microtingCheckUId1", "microtingUId1",
                                                             site1, 1, "caseType1", unit, c1_ua, 1, worker, Constants.WorkflowStates.Created);

            uploaded_data ud = new uploaded_data();

            ud.checksum      = "checksum1";
            ud.extension     = "extension";
            ud.current_file  = "currentFile1";
            ud.uploader_id   = 223;
            ud.uploader_type = "uploader_type";
            ud.file_location = "url";
            ud.file_name     = "fileName";
            //ud.id = 111;

            DbContext.uploaded_data.Add(ud);
            DbContext.SaveChanges();

            field_values fVs = new field_values();

            fVs.uploaded_data_id = ud.id;
            fVs.case_id          = aCase1.id;

            DbContext.field_values.Add(fVs);
            DbContext.SaveChanges();


            //Act
            sut.FileCaseFindMUId("url");


            Assert.NotNull(fVs);
            Assert.AreEqual(fVs.case_id, aCase1.id);
        }
Exemple #12
0
        public void CaseCompleted(object sender, EventArgs args)
        {
            eFormShared.Case_Dto trigger    = (eFormShared.Case_Dto)sender;
            check_lists          check_list = sqlController.CheckListRead(trigger.CheckListId);
            List <fields>        fields     = sqlController.FieldsOnCheckList(check_list.id);

            if (fields != null)
            {
                List <eFormData.FieldValue> caseFieldValues = new List <eFormData.FieldValue>();
                if (sqlController.CheckListRead(trigger.CheckListId) != null)
                {
                    List <eFormShared.Field_Dto> eFormFields = sdkCore.Advanced_TemplateFieldReadAll(trigger.CheckListId);
                    List <int> field_ids = new List <int>();
                    foreach (eFormShared.Field_Dto f in eFormFields)
                    {
                        field_ids.Add(f.Id);
                    }
                    foreach (fields field in fields)
                    {
                        if (field_ids.Contains((int)field.sdk_field_id))
                        {
                            eFormData.FieldValue fv = sdkCore.Advanced_FieldValueReadList((int)field.sdk_field_id, 1)[0];
                            caseFieldValues.Add(fv);
                        }
                    }
                }

                bool shouldSkipValues = false;
                foreach (eFormData.FieldValue fv in caseFieldValues)
                {
                    if (fv.FieldId == check_list.reset_values_field_id)
                    {
                        if (fv.Value == "checked")
                        {
                            shouldSkipValues = true;
                        }
                    }
                }

                sdkCore.CaseDelete(trigger.CheckListId, trigger.SiteUId);

                eFormData.MainElement eform = sdkCore.TemplateRead(trigger.CheckListId);
                if (!shouldSkipValues)
                {
                    SetDefaultValue(eform.ElementList, caseFieldValues);
                }

                eform.EndDate = DateTime.Now.AddYears(1);
                sdkCore.CaseCreate(eform, "", trigger.SiteUId);
            }
        }
Exemple #13
0
        public async Task Core_Template_TemplateDelete_SetsWorkflowStateToRemoved()
        {
            // Arrange
            #region Tempalte1

            DateTime    cl1_ca = DateTime.Now;
            DateTime    cl1_ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_ca, cl1_ua, "A", "D", "CheckList", "Template1FolderName", 1, 1);

            #endregion
            #region Tempalte2

            DateTime    cl2_ca = DateTime.Now;
            DateTime    cl2_ua = DateTime.Now;
            check_lists cl2    = await testHelpers.CreateTemplate(cl2_ca, cl2_ua, "A", "D", "CheckList", "Template1FolderName", 1, 1);

            #endregion
            #region Tempalte3

            DateTime    cl3_ca = DateTime.Now;
            DateTime    cl3_ua = DateTime.Now;
            check_lists cl3    = await testHelpers.CreateTemplate(cl3_ca, cl3_ua, "A", "D", "CheckList", "Template1FolderName", 1, 1);

            #endregion
            #region Tempalte4

            DateTime    cl4_ca = DateTime.Now;
            DateTime    cl4_ua = DateTime.Now;
            check_lists cl4    = await testHelpers.CreateTemplate(cl4_ca, cl4_ua, "A", "D", "CheckList", "Template1FolderName", 1, 1);

            #endregion
            // Act
            var deleteTemplate1 = await sut.TemplateDelete(cl1.Id);

            var deleteTemplate2 = await sut.TemplateDelete(cl2.Id);

            var deleteTemplate3 = await sut.TemplateDelete(cl3.Id);

            var deleteTemplate4 = await sut.TemplateDelete(cl4.Id);

            // Assert
            Assert.NotNull(deleteTemplate1);
            Assert.NotNull(deleteTemplate2);
            Assert.NotNull(deleteTemplate3);
            Assert.NotNull(deleteTemplate4);
            Assert.True(deleteTemplate1);
            Assert.True(deleteTemplate2);
            Assert.True(deleteTemplate3);
            Assert.True(deleteTemplate4);
        }
Exemple #14
0
        public check_list_sites CreateCheckListSite(check_lists checklist, DateTime createdAt,
                                                    sites site, DateTime updatedAt, int version, string workflowState, string microting_uid)
        {
            check_list_sites cls = new check_list_sites();

            cls.check_list     = checklist;
            cls.created_at     = createdAt;
            cls.site           = site;
            cls.updated_at     = updatedAt;
            cls.version        = version;
            cls.workflow_state = workflowState;
            cls.microting_uid  = microting_uid;
            DbContext.check_list_sites.Add(cls);
            DbContext.SaveChanges();
            return(cls);
        }
Exemple #15
0
        public check_list_values CreateCheckListValue(cases aCase, check_lists checkList, string status, int?userId, int?version)
        {
            check_list_values CLV = new check_list_values();

            CLV.case_id        = aCase.id;
            CLV.check_list_id  = checkList.id;
            CLV.created_at     = DateTime.Now;
            CLV.status         = status;
            CLV.updated_at     = DateTime.Now;
            CLV.user_id        = userId;
            CLV.version        = version;
            CLV.workflow_state = Constants.WorkflowStates.Created;

            DbContext.check_list_values.Add(CLV);
            DbContext.SaveChanges();
            return(CLV);
        }
        public async Task <check_list_values> CreateCheckListValue(cases aCase, check_lists checkList, string status, int?userId, int?version)
        {
            check_list_values CLV = new check_list_values();

            CLV.CaseId        = aCase.Id;
            CLV.CheckListId   = checkList.Id;
            CLV.CreatedAt     = DateTime.UtcNow;
            CLV.Status        = status;
            CLV.UpdatedAt     = DateTime.UtcNow;
            CLV.UserId        = userId;
            CLV.Version       = version;
            CLV.WorkflowState = Constants.WorkflowStates.Created;

            dbContext.check_list_values.Add(CLV);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(CLV);
        }
        public check_lists CreateTemplate(string label, string description, string caseType, string folderName, int displayIndex, int repeated)
        {
            check_lists cl1 = new check_lists();

            cl1.created_at     = DateTime.Now;
            cl1.updated_at     = DateTime.Now;
            cl1.label          = label;
            cl1.description    = description;
            cl1.workflow_state = Constants.WorkflowStates.Created;
            cl1.case_type      = caseType;
            cl1.folder_name    = folderName;
            cl1.display_index  = displayIndex;
            cl1.repeated       = repeated;

            DbContext.check_lists.Add(cl1);
            DbContext.SaveChanges();
            return(cl1);
        }
Exemple #18
0
        public check_lists CreateSubTemplate(string label, string description, string caseType, int displayIndex, int repeated, check_lists parentId)
        {
            check_lists cl2 = new check_lists();

            cl2.created_at     = DateTime.Now;
            cl2.updated_at     = DateTime.Now;
            cl2.label          = label;
            cl2.description    = description;
            cl2.workflow_state = Constants.WorkflowStates.Created;
            cl2.case_type      = caseType;
            cl2.display_index  = displayIndex;
            cl2.repeated       = repeated;
            cl2.parent_id      = parentId.id;

            DbContext.check_lists.Add(cl2);
            DbContext.SaveChanges();
            return(cl2);
        }
        public async Task <check_list_sites> CreateCheckListSite(check_lists checklist, DateTime createdAt,
                                                                 sites site, DateTime updatedAt, int version, string workflowState, int microting_uid)
        {
            check_list_sites cls = new check_list_sites();

            cls.CheckList     = checklist;
            cls.CreatedAt     = createdAt;
            cls.Site          = site;
            cls.UpdatedAt     = updatedAt;
            cls.Version       = version;
            cls.WorkflowState = workflowState;
            cls.MicrotingUid  = microting_uid;
            await cls.Create(dbContext).ConfigureAwait(false);

//            DbContext.check_list_sites.Add(cls);
//            await dbContext.SaveChangesAsync().ConfigureAwait(false);
            return(cls);
        }
Exemple #20
0
        public fields CreateField(short?barcodeEnabled, string barcodeType, check_lists checkList, string color, string custom, int?decimalCount, string defaultValue, string description, int?displayIndex, short?dummy, field_types ft, short?geolocationEnabled, short?geolocationForced, short?geolocationHidden, short?isNum, string label, short?mandatory, int maxLength, string maxValue, string minValue, short?multi, short?optional, string queryType, short?readOnly, short?selected, short?splitScreen, short?stopOnSave, string unitName, int version)
        {
            fields f = new fields();

            f.field_type_id = ft.id;

            f.barcode_enabled     = barcodeEnabled;
            f.barcode_type        = barcodeType;
            f.check_list_id       = checkList.id;
            f.color               = color;
            f.created_at          = DateTime.Now;
            f.custom              = custom;
            f.decimal_count       = decimalCount;
            f.default_value       = defaultValue;
            f.description         = description;
            f.display_index       = displayIndex;
            f.dummy               = dummy;
            f.geolocation_enabled = geolocationEnabled;
            f.geolocation_forced  = geolocationForced;
            f.geolocation_hidden  = geolocationHidden;
            f.is_num              = isNum;
            f.label               = label;
            f.mandatory           = mandatory;
            f.max_length          = maxLength;
            f.max_value           = maxValue;
            f.min_value           = minValue;
            f.multi               = multi;
            f.optional            = optional;
            f.query_type          = queryType;
            f.read_only           = readOnly;
            f.selected            = selected;
            f.split_screen        = splitScreen;
            f.stop_on_save        = stopOnSave;
            f.unit_name           = unitName;
            f.updated_at          = DateTime.Now;
            f.version             = version;
            f.workflow_state      = Constants.WorkflowStates.Created;

            DbContext.fields.Add(f);
            DbContext.SaveChanges();
            Thread.Sleep(2000);

            return(f);
        }
Exemple #21
0
        public async Task SQL_Tags_TemplateSetTags_DoesAssignTagToTemplate()
        {
            // Arrance
            check_lists cl1 = new check_lists
            {
                CreatedAt     = DateTime.Now,
                UpdatedAt     = DateTime.Now,
                Label         = "A",
                Description   = "D",
                WorkflowState = Constants.WorkflowStates.Created,
                CaseType      = "CheckList",
                FolderName    = "Template1FolderName",
                DisplayIndex  = 1,
                Repeated      = 1
            };

            dbContext.check_lists.Add(cl1);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            string tagName1 = "Tag1";
            tags   tag      = new tags
            {
                Name          = tagName1,
                WorkflowState = Constants.WorkflowStates.Created
            };

            dbContext.tags.Add(tag);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            // Act
            List <int> tags = new List <int> {
                tag.Id
            };
            await sut.TemplateSetTags(cl1.Id, tags);


            // Assert
            List <taggings> result = dbContext.taggings.AsNoTracking().ToList();

            Assert.AreEqual(1, result.Count());
            Assert.AreEqual(tag.Id, result[0].TagId);
            Assert.AreEqual(cl1.Id, result[0].CheckListId);
            Assert.True(true);
        }
        public async Task <check_lists> CreateSubTemplate(string label, string description, string caseType, int displayIndex, int repeated, check_lists parentId)
        {
            check_lists cl2 = new check_lists();

            cl2.CreatedAt     = DateTime.UtcNow;
            cl2.UpdatedAt     = DateTime.UtcNow;
            cl2.Label         = label;
            cl2.Description   = description;
            cl2.WorkflowState = Constants.WorkflowStates.Created;
            cl2.CaseType      = caseType;
            cl2.DisplayIndex  = displayIndex;
            cl2.Repeated      = repeated;
            cl2.ParentId      = parentId.Id;

            dbContext.check_lists.Add(cl2);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(cl2);
        }
Exemple #23
0
        public void SQL_Tags_TemplateSetTags_DoesAssignTagToTemplate()
        {
            // Arrance
            check_lists cl1 = new check_lists();

            cl1.created_at     = DateTime.Now;
            cl1.updated_at     = DateTime.Now;
            cl1.label          = "A";
            cl1.description    = "D";
            cl1.workflow_state = Constants.WorkflowStates.Created;
            cl1.case_type      = "CheckList";
            cl1.folder_name    = "Template1FolderName";
            cl1.display_index  = 1;
            cl1.repeated       = 1;

            DbContext.check_lists.Add(cl1);
            DbContext.SaveChanges();

            string tagName1 = "Tag1";
            tags   tag      = new tags();

            tag.name           = tagName1;
            tag.workflow_state = Constants.WorkflowStates.Created;

            DbContext.tags.Add(tag);
            DbContext.SaveChanges();

            // Act
            List <int> tags = new List <int>();

            tags.Add(tag.id);
            sut.TemplateSetTags(cl1.id, tags);


            // Assert
            List <taggings> result = DbContext.taggings.AsNoTracking().ToList();

            Assert.AreEqual(1, result.Count());
            Assert.AreEqual(tag.id, result[0].tag_id);
            Assert.AreEqual(cl1.id, result[0].check_list_id);
            Assert.True(true);
        }
Exemple #24
0
        public void SQL_Case_CheckListSitesCreate_DoesSiteCreate()
        {
            sites       site   = testHelpers.CreateSite("mySite", 987);
            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template", "template_desc", "", "", 0, 0);


            // Act
            sut.CheckListSitesCreate(cl1.id, (int)site.microting_uid, "ServerMicrotingUid");
            List <check_list_sites> checkListSiteResult = DbContext.check_list_sites.AsNoTracking().ToList();
            var versionedMatches = DbContext.check_list_site_versions.AsNoTracking().ToList();

            // Assert

            Assert.NotNull(checkListSiteResult);
            Assert.AreEqual(1, checkListSiteResult.Count);
            Assert.AreEqual(Constants.WorkflowStates.Created, checkListSiteResult[0].workflow_state);
            Assert.AreEqual(Constants.WorkflowStates.Created, versionedMatches[0].workflow_state);
        }
        public async Task <check_lists> CreateTemplate(DateTime cl_ca, DateTime cl_ua, string label, string description, string caseType, string folderName, int displayIndex, int repeated)
        {
            check_lists cl1 = new check_lists();

            cl1.CreatedAt     = cl_ca;
            cl1.UpdatedAt     = cl_ua;
            cl1.Label         = label;
            cl1.Description   = description;
            cl1.WorkflowState = Constants.WorkflowStates.Created;
            cl1.CaseType      = caseType;
            cl1.FolderName    = folderName;
            cl1.DisplayIndex  = displayIndex;
            cl1.Repeated      = repeated;
            cl1.ParentId      = 0;

            dbContext.check_lists.Add(cl1);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(cl1);
        }
Exemple #26
0
        public async Task SQL_Case_CheckListSitesCreate_DoesSiteCreate()
        {
            Random rnd  = new Random();
            sites  site = await testHelpers.CreateSite("mySite", 987);

            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "template", "template_desc", "", "", 0, 0);


            // Act
            await sut.CheckListSitesCreate(cl1.Id, (int)site.MicrotingUid, rnd.Next(1, 255), null);

            List <check_list_sites> checkListSiteResult = dbContext.check_list_sites.AsNoTracking().ToList();
            var versionedMatches = dbContext.check_list_site_versions.AsNoTracking().ToList();

            // Assert

            Assert.NotNull(checkListSiteResult);
            Assert.AreEqual(1, checkListSiteResult.Count);
            Assert.AreEqual(Constants.WorkflowStates.Created, checkListSiteResult[0].WorkflowState);
            Assert.AreEqual(Constants.WorkflowStates.Created, versionedMatches[0].WorkflowState);
        }
Exemple #27
0
        public void SQL_Case_CaseDeleteReversed_DoesDeletionReversed()
        {
            // Arrance
            sites       site   = testHelpers.CreateSite("mySite", 987);
            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "bla", "bla_desc", "", "", 0, 0);

            string guid          = Guid.NewGuid().ToString();
            string lastCheckUid1 = Guid.NewGuid().ToString();


            check_list_sites cls1 = testHelpers.CreateCheckListSite(cl1, cl1_Ca, site, cl1_Ua, 1, Constants.WorkflowStates.Created, lastCheckUid1);

            // Act
            sut.CaseDeleteReversed(cls1.microting_uid);
            List <check_list_sites> checkListSiteResult = DbContext.check_list_sites.AsNoTracking().ToList();

            // Assert

            Assert.NotNull(checkListSiteResult);
            Assert.AreEqual(1, checkListSiteResult.Count);
            Assert.AreEqual(Constants.WorkflowStates.Removed, checkListSiteResult[0].workflow_state);
        }
Exemple #28
0
        public async Task Core_Template_TemplateRead_ReturnsTemplate()
        {
            // Arrange
            #region Tempalte

            DateTime    cl1_ca = DateTime.Now;
            DateTime    cl1_ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_ca, cl1_ua, "A", "D", "CheckList", "Template1FolderName", 1, 1);

            #endregion

            // Act
            var match = await sut.TemplateRead(cl1.Id);

            // Assert
            Assert.NotNull(match);
            Assert.AreEqual(match.Id, cl1.Id);
            Assert.AreEqual(match.CaseType, cl1.CaseType);
            Assert.AreEqual(match.FastNavigation, false);
            Assert.AreEqual(match.Label, cl1.Label);
            Assert.AreEqual(match.ManualSync, false);
            Assert.AreEqual(match.MultiApproval, false);
            Assert.AreEqual(match.Repeated, cl1.Repeated);
        }
Exemple #29
0
        public async Task SQL_Check_CheckRead_ReturnsReplyElement()
        {
            // Arrance
            #region Arrance
            Random rnd = new Random();
            #region Template1
            DateTime    cl1_Ca = DateTime.Now;
            DateTime    cl1_Ua = DateTime.Now;
            check_lists cl1    = await testHelpers.CreateTemplate(cl1_Ca, cl1_Ua, "A", "D", "CheckList", "Template1FolderName", 1, 1);

            #endregion

            #region SubTemplate1
            check_lists cl2 = await testHelpers.CreateSubTemplate("A.1", "D.1", "CheckList", 1, 1, cl1);

            #endregion

            #region Fields
            #region field1


            fields f1 = await testHelpers.CreateField(1, "barcode", cl2, "e2f4fb", "custom", null, "", "Comment field description",
                                                      5, 1, dbContext.field_types.Where(x => x.FieldType == "comment").First(), 0, 0, 1, 0, "Comment field", 1, 55, "55", "0", 0, 0, null, 1, 0,
                                                      0, 0, "", 49);

            #endregion

            #region field2


            fields f2 = await testHelpers.CreateField(1, "barcode", cl2, "f5eafa", "custom", null, "", "showPDf Description",
                                                      45, 1, dbContext.field_types.Where(x => x.FieldType == "comment").First(), 0, 1, 0, 0,
                                                      "ShowPdf", 0, 5, "5", "0", 0, 0, null, 0, 0, 0, 0, "", 9);

            #endregion

            #region field3

            fields f3 = await testHelpers.CreateField(0, "barcode", cl2, "f0f8db", "custom", 3, "", "Number Field Description",
                                                      83, 0, dbContext.field_types.Where(x => x.FieldType == "number").First(), 0, 0, 1, 0,
                                                      "Numberfield", 1, 8, "4865", "0", 0, 1, null, 1, 0, 0, 0, "", 1);

            #endregion

            #region field4


            fields f4 = await testHelpers.CreateField(1, "barcode", cl2, "fff6df", "custom", null, "", "date Description",
                                                      84, 0, dbContext.field_types.Where(x => x.FieldType == "comment").First(), 0, 0, 1, 0,
                                                      "Date", 1, 666, "41153", "0", 0, 1, null, 0, 1, 0, 0, "", 1);

            #endregion

            #region field5

            fields f5 = await testHelpers.CreateField(0, "barcode", cl2, "ffe4e4", "custom", null, "", "picture Description",
                                                      85, 0, dbContext.field_types.Where(x => x.FieldType == "comment").First(), 1, 0, 1, 0,
                                                      "Picture", 1, 69, "69", "1", 0, 1, null, 0, 1, 0, 0, "", 1);

            #endregion
            #endregion

            #region Worker

            workers worker = await testHelpers.CreateWorker("*****@*****.**", "Arne", "Jensen", 21);

            #endregion

            #region site
            sites site = await testHelpers.CreateSite("SiteName", 88);

            #endregion

            #region units
            units unit = await testHelpers.CreateUnit(48, 49, site, 348);

            #endregion

            #region site_workers
            site_workers site_workers = await testHelpers.CreateSiteWorker(55, site, worker);

            #endregion

            #region Case1

            cases aCase = await testHelpers.CreateCase("caseUId", cl1, DateTime.Now, "custom", DateTime.Now,
                                                       worker, rnd.Next(1, 255), rnd.Next(1, 255),
                                                       site, 66, "caseType", unit, DateTime.Now, 1, worker, Constants.WorkflowStates.Created);

            #endregion

            #region Check List Values
            check_list_values check_List_Values = await testHelpers.CreateCheckListValue(aCase, cl2, "completed", null, 865);


            #endregion

            #region Field Values
            #region fv1
            field_values field_Values1 = await testHelpers.CreateFieldValue(aCase, cl2, f1, null, null, "tomt1", 61234, worker);

            #endregion

            #region fv2
            field_values field_Values2 = await testHelpers.CreateFieldValue(aCase, cl2, f2, null, null, "tomt2", 61234, worker);

            #endregion

            #region fv3
            field_values field_Values3 = await testHelpers.CreateFieldValue(aCase, cl2, f3, null, null, "tomt3", 61234, worker);

            #endregion

            #region fv4
            field_values field_Values4 = await testHelpers.CreateFieldValue(aCase, cl2, f4, null, null, "tomt4", 61234, worker);

            #endregion

            #region fv5
            field_values field_Values5 = await testHelpers.CreateFieldValue(aCase, cl2, f5, null, null, "tomt5", 61234, worker);

            #endregion


            #endregion

            #endregion
            // Act

            ReplyElement match = await sut.CheckRead((int)aCase.MicrotingUid, (int)aCase.MicrotingCheckUid);

            // Assert
            #region Assert

            Assert.AreEqual(1, match.ElementList.Count());
            CheckListValue clv = (CheckListValue)match.ElementList[0];
            Assert.AreEqual(5, clv.DataItemList.Count);
            #region casts
            Field _f1 = (Field)clv.DataItemList[0];
            Field _f2 = (Field)clv.DataItemList[1];
            Field _f3 = (Field)clv.DataItemList[2];
            Field _f4 = (Field)clv.DataItemList[3];
            Field _f5 = (Field)clv.DataItemList[4];


            #endregion

            #region Barcode
            Assert.AreEqual(f1.BarcodeEnabled, 1);
            Assert.AreEqual(f2.BarcodeEnabled, 1);
            Assert.AreEqual(f3.BarcodeEnabled, 0);
            Assert.AreEqual(f4.BarcodeEnabled, 1);
            Assert.AreEqual(f5.BarcodeEnabled, 0);

            Assert.AreEqual(f1.BarcodeType, "barcode");
            Assert.AreEqual(f2.BarcodeType, "barcode");
            Assert.AreEqual(f3.BarcodeType, "barcode");
            Assert.AreEqual(f4.BarcodeType, "barcode");
            Assert.AreEqual(f5.BarcodeType, "barcode");
            #endregion

            #region chckl_id

            Assert.AreEqual(f1.CheckListId, cl2.Id);
            Assert.AreEqual(f2.CheckListId, cl2.Id);
            Assert.AreEqual(f3.CheckListId, cl2.Id);
            Assert.AreEqual(f4.CheckListId, cl2.Id);
            Assert.AreEqual(f5.CheckListId, cl2.Id);


            #endregion

            #region Color
            Assert.AreEqual(f1.Color, _f1.FieldValues[0].Color);
            Assert.AreEqual(f2.Color, _f2.FieldValues[0].Color);
            Assert.AreEqual(f3.Color, _f3.FieldValues[0].Color);
            Assert.AreEqual(f4.Color, _f4.FieldValues[0].Color);
            Assert.AreEqual(f5.Color, _f5.FieldValues[0].Color);
            #endregion

            #region custom
            //  Assert.AreEqual(f1.custom, _f1.FieldValues[0].Id);
            #endregion

            #region Decimal_Count
            Assert.AreEqual(f1.DecimalCount, null);
            Assert.AreEqual(f2.DecimalCount, null);
            Assert.AreEqual(f3.DecimalCount, 3);
            Assert.AreEqual(f4.DecimalCount, null);
            Assert.AreEqual(f5.DecimalCount, null);

            #endregion

            #region Default_value
            Assert.AreEqual(f1.DefaultValue, "");
            Assert.AreEqual(f2.DefaultValue, "");
            Assert.AreEqual(f3.DefaultValue, "");
            Assert.AreEqual(f4.DefaultValue, "");
            Assert.AreEqual(f5.DefaultValue, "");
            #endregion

            #region Description
            CDataValue f1desc = (CDataValue)_f1.Description;
            CDataValue f2desc = (CDataValue)_f2.Description;
            CDataValue f3desc = (CDataValue)_f3.Description;
            CDataValue f4desc = (CDataValue)_f4.Description;
            CDataValue f5desc = (CDataValue)_f5.Description;

            Assert.AreEqual(f1.Description, f1desc.InderValue);
            Assert.AreEqual(f2.Description, f2desc.InderValue);
            Assert.AreEqual(f3.Description, f3desc.InderValue);
            Assert.AreEqual(f4.Description, f4desc.InderValue);
            Assert.AreEqual(f5.Description, f5desc.InderValue);
            #endregion

            #region Displayindex
            Assert.AreEqual(f1.DisplayIndex, _f1.FieldValues[0].DisplayOrder);
            Assert.AreEqual(f2.DisplayIndex, _f2.FieldValues[0].DisplayOrder);
            Assert.AreEqual(f3.DisplayIndex, _f3.FieldValues[0].DisplayOrder);
            Assert.AreEqual(f4.DisplayIndex, _f4.FieldValues[0].DisplayOrder);
            Assert.AreEqual(f5.DisplayIndex, _f5.FieldValues[0].DisplayOrder);
            #endregion

            #region Dummy
            Assert.AreEqual(f1.Dummy, 1);
            Assert.AreEqual(f2.Dummy, 1);
            Assert.AreEqual(f3.Dummy, 0);
            Assert.AreEqual(f4.Dummy, 0);
            Assert.AreEqual(f5.Dummy, 0);
            #endregion

            #region geolocation
            #region enabled
            Assert.AreEqual(f1.GeolocationEnabled, 0);
            Assert.AreEqual(f2.GeolocationEnabled, 0);
            Assert.AreEqual(f3.GeolocationEnabled, 0);
            Assert.AreEqual(f4.GeolocationEnabled, 0);
            Assert.AreEqual(f5.GeolocationEnabled, 1);
            #endregion
            #region forced
            Assert.AreEqual(f1.GeolocationForced, 0);
            Assert.AreEqual(f2.GeolocationForced, 1);
            Assert.AreEqual(f3.GeolocationForced, 0);
            Assert.AreEqual(f4.GeolocationForced, 0);
            Assert.AreEqual(f5.GeolocationForced, 0);
            #endregion
            #region hidden
            Assert.AreEqual(f1.GeolocationHidden, 1);
            Assert.AreEqual(f2.GeolocationHidden, 0);
            Assert.AreEqual(f3.GeolocationHidden, 1);
            Assert.AreEqual(f4.GeolocationHidden, 1);
            Assert.AreEqual(f5.GeolocationHidden, 1);
            #endregion

            #endregion

            #region isNum
            Assert.AreEqual(f1.IsNum, 0);
            Assert.AreEqual(f2.IsNum, 0);
            Assert.AreEqual(f3.IsNum, 0);
            Assert.AreEqual(f4.IsNum, 0);
            Assert.AreEqual(f5.IsNum, 0);


            #endregion

            #region Label
            Assert.AreEqual(f1.Label, _f1.Label);
            Assert.AreEqual(f2.Label, _f2.Label);
            Assert.AreEqual(f3.Label, _f3.Label);
            Assert.AreEqual(f4.Label, _f4.Label);
            Assert.AreEqual(f5.Label, _f5.Label);
            #endregion

            #region Mandatory
            Assert.AreEqual(f1.Mandatory, 1);
            Assert.AreEqual(f2.Mandatory, 0);
            Assert.AreEqual(f3.Mandatory, 1);
            Assert.AreEqual(f4.Mandatory, 1);
            Assert.AreEqual(f5.Mandatory, 1);
            #endregion

            #region maxLength
            Assert.AreEqual(f1.MaxLength, 55);
            Assert.AreEqual(f2.MaxLength, 5);
            Assert.AreEqual(f3.MaxLength, 8);
            Assert.AreEqual(f4.MaxLength, 666);
            Assert.AreEqual(f5.MaxLength, 69);

            #endregion

            #region min/max_Value
            #region max
            Assert.AreEqual(f1.MaxValue, "55");
            Assert.AreEqual(f2.MaxValue, "5");
            Assert.AreEqual(f3.MaxValue, "4865");
            Assert.AreEqual(f4.MaxValue, "41153");
            Assert.AreEqual(f5.MaxValue, "69");
            #endregion
            #region min
            Assert.AreEqual(f1.MinValue, "0");
            Assert.AreEqual(f2.MinValue, "0");
            Assert.AreEqual(f3.MinValue, "0");
            Assert.AreEqual(f4.MinValue, "0");
            Assert.AreEqual(f5.MinValue, "1");
            #endregion
            #endregion

            #region Multi
            Assert.AreEqual(f1.Multi, 0);
            Assert.AreEqual(f2.Multi, 0);
            Assert.AreEqual(f3.Multi, 0);
            Assert.AreEqual(f4.Multi, 0);
            Assert.AreEqual(f5.Multi, 0);
            #endregion

            #region Optional
            Assert.AreEqual(f1.Optional, 0);
            Assert.AreEqual(f2.Optional, 0);
            Assert.AreEqual(f3.Optional, 1);
            Assert.AreEqual(f4.Optional, 1);
            Assert.AreEqual(f5.Optional, 1);

            #endregion

            #region Query_Type
            Assert.AreEqual(f1.QueryType, null);
            Assert.AreEqual(f2.QueryType, null);
            Assert.AreEqual(f3.QueryType, null);
            Assert.AreEqual(f4.QueryType, null);
            Assert.AreEqual(f5.QueryType, null);

            #endregion

            #region Read_Only
            Assert.AreEqual(f1.ReadOnly, 1);
            Assert.AreEqual(f2.ReadOnly, 0);
            Assert.AreEqual(f3.ReadOnly, 1);
            Assert.AreEqual(f4.ReadOnly, 0);
            Assert.AreEqual(f5.ReadOnly, 0);
            #endregion

            #region Selected
            Assert.AreEqual(f1.Selected, 0);
            Assert.AreEqual(f2.Selected, 0);
            Assert.AreEqual(f3.Selected, 0);
            Assert.AreEqual(f4.Selected, 1);
            Assert.AreEqual(f5.Selected, 1);
            #endregion

            #region Split_Screen
            Assert.AreEqual(f1.SplitScreen, 0);
            Assert.AreEqual(f2.SplitScreen, 0);
            Assert.AreEqual(f3.SplitScreen, 0);
            Assert.AreEqual(f4.SplitScreen, 0);
            Assert.AreEqual(f5.SplitScreen, 0);

            #endregion

            #region Stop_On_Save
            Assert.AreEqual(f1.StopOnSave, 0);
            Assert.AreEqual(f2.StopOnSave, 0);
            Assert.AreEqual(f3.StopOnSave, 0);
            Assert.AreEqual(f4.StopOnSave, 0);
            Assert.AreEqual(f5.StopOnSave, 0);
            #endregion

            #region Unit_Name
            Assert.AreEqual(f1.UnitName, "");
            Assert.AreEqual(f2.UnitName, "");
            Assert.AreEqual(f3.UnitName, "");
            Assert.AreEqual(f4.UnitName, "");
            Assert.AreEqual(f5.UnitName, "");
            #endregion

            #region Values

            Assert.AreEqual(1, _f1.FieldValues.Count());
            Assert.AreEqual(1, _f2.FieldValues.Count());
            Assert.AreEqual(1, _f3.FieldValues.Count());
            Assert.AreEqual(1, _f4.FieldValues.Count());
            Assert.AreEqual(1, _f5.FieldValues.Count());

            Assert.AreEqual(field_Values1.Value, _f1.FieldValues[0].Value);
            Assert.AreEqual(field_Values2.Value, _f2.FieldValues[0].Value);
            Assert.AreEqual(field_Values3.Value, _f3.FieldValues[0].Value);
            Assert.AreEqual(field_Values4.Value, _f4.FieldValues[0].Value);
            Assert.AreEqual(field_Values5.Value, _f5.FieldValues[0].Value);
            #endregion

            #region Version
            Assert.AreEqual(f1.Version, 49);
            Assert.AreEqual(f2.Version, 9);
            Assert.AreEqual(f3.Version, 1);
            Assert.AreEqual(f4.Version, 1);
            Assert.AreEqual(f5.Version, 1);
            #endregion

            #endregion
        }
Exemple #30
0
        public async Task FieldValues_Delete_DoesSetWorkflowStateToRemoved()
        {
            short shortMinValue = Int16.MinValue;
            short shortmaxValue = Int16.MaxValue;

            Random rnd = new Random();

            bool randomBool = rnd.Next(0, 2) > 0;

            sites site = new sites
            {
                Name         = Guid.NewGuid().ToString(),
                MicrotingUid = rnd.Next(1, 255)
            };
            await site.Create(dbContext).ConfigureAwait(false);

            units unit = new units
            {
                CustomerNo   = rnd.Next(1, 255),
                MicrotingUid = rnd.Next(1, 255),
                OtpCode      = rnd.Next(1, 255),
                SiteId       = site.Id
            };
            await unit.Create(dbContext).ConfigureAwait(false);

            check_lists checklist = new check_lists
            {
                Color               = Guid.NewGuid().ToString(),
                Custom              = Guid.NewGuid().ToString(),
                Description         = Guid.NewGuid().ToString(),
                Field1              = rnd.Next(1, 255),
                Field2              = rnd.Next(1, 255),
                Field4              = rnd.Next(1, 255),
                Field5              = rnd.Next(1, 255),
                Field6              = rnd.Next(1, 255),
                Field7              = rnd.Next(1, 255),
                Field8              = rnd.Next(1, 255),
                Field9              = rnd.Next(1, 255),
                Field10             = rnd.Next(1, 255),
                Label               = Guid.NewGuid().ToString(),
                Repeated            = rnd.Next(1, 255),
                ApprovalEnabled     = (short)rnd.Next(shortMinValue, shortmaxValue),
                CaseType            = Guid.NewGuid().ToString(),
                DisplayIndex        = rnd.Next(1, 255),
                DownloadEntities    = (short)rnd.Next(shortMinValue, shortmaxValue),
                FastNavigation      = (short)rnd.Next(shortMinValue, shortmaxValue),
                FolderName          = Guid.NewGuid().ToString(),
                ManualSync          = (short)rnd.Next(shortMinValue, shortmaxValue),
                MultiApproval       = (short)rnd.Next(shortMinValue, shortmaxValue),
                OriginalId          = Guid.NewGuid().ToString(),
                ReviewEnabled       = (short)rnd.Next(shortMinValue, shortmaxValue),
                DocxExportEnabled   = randomBool,
                DoneButtonEnabled   = (short)rnd.Next(shortMinValue, shortmaxValue),
                ExtraFieldsEnabled  = (short)rnd.Next(shortMinValue, shortmaxValue),
                JasperExportEnabled = randomBool,
                QuickSyncEnabled    = (short)rnd.Next(shortMinValue, shortmaxValue)
            };
            await checklist.Create(dbContext).ConfigureAwait(false);

            entity_groups entityGroup = new entity_groups
            {
                Name         = Guid.NewGuid().ToString(),
                Type         = Guid.NewGuid().ToString(),
                MicrotingUid = Guid.NewGuid().ToString()
            };
            await entityGroup.Create(dbContext).ConfigureAwait(false);

            field_types fieldType = new field_types
            {
                Description = Guid.NewGuid().ToString(),
                FieldType   = Guid.NewGuid().ToString()
            };
            await fieldType.Create(dbContext).ConfigureAwait(false);

            fields field = new fields
            {
                Color              = Guid.NewGuid().ToString(),
                Custom             = Guid.NewGuid().ToString(),
                Description        = Guid.NewGuid().ToString(),
                Dummy              = (short)rnd.Next(shortMinValue, shortmaxValue),
                Label              = Guid.NewGuid().ToString(),
                Mandatory          = (short)rnd.Next(shortMinValue, shortmaxValue),
                Multi              = rnd.Next(1, 255),
                Optional           = (short)rnd.Next(shortMinValue, shortmaxValue),
                Selected           = (short)rnd.Next(shortMinValue, shortmaxValue),
                BarcodeEnabled     = (short)rnd.Next(shortMinValue, shortmaxValue),
                BarcodeType        = Guid.NewGuid().ToString(),
                DecimalCount       = rnd.Next(1, 255),
                DefaultValue       = Guid.NewGuid().ToString(),
                DisplayIndex       = rnd.Next(1, 255),
                GeolocationEnabled = (short)rnd.Next(shortMinValue, shortmaxValue),
                GeolocationForced  = (short)rnd.Next(shortMinValue, shortmaxValue),
                GeolocationHidden  = (short)rnd.Next(shortMinValue, shortmaxValue),
                IsNum              = (short)rnd.Next(shortMinValue, shortmaxValue),
                MaxLength          = rnd.Next(1, 255),
                MaxValue           = Guid.NewGuid().ToString(),
                MinValue           = Guid.NewGuid().ToString(),
                OriginalId         = Guid.NewGuid().ToString(),
                QueryType          = Guid.NewGuid().ToString(),
                ReadOnly           = (short)rnd.Next(shortMinValue, shortmaxValue),
                SplitScreen        = (short)rnd.Next(shortMinValue, shortmaxValue),
                UnitName           = Guid.NewGuid().ToString(),
                StopOnSave         = (short)rnd.Next(shortMinValue, shortmaxValue),
                KeyValuePairList   = Guid.NewGuid().ToString(),
                CheckListId        = checklist.Id,
                EntityGroupId      = entityGroup.Id,
                FieldTypeId        = fieldType.Id
            };
            await field.Create(dbContext).ConfigureAwait(false);

            workers worker = new workers
            {
                Email        = Guid.NewGuid().ToString(),
                FirstName    = Guid.NewGuid().ToString(),
                LastName     = Guid.NewGuid().ToString(),
                MicrotingUid = rnd.Next(1, 255)
            };
            await worker.Create(dbContext).ConfigureAwait(false);

            cases theCase = new cases
            {
                Custom            = Guid.NewGuid().ToString(),
                Status            = rnd.Next(1, 255),
                Type              = Guid.NewGuid().ToString(),
                CaseUid           = Guid.NewGuid().ToString(),
                DoneAt            = DateTime.Now,
                FieldValue1       = Guid.NewGuid().ToString(),
                FieldValue2       = Guid.NewGuid().ToString(),
                FieldValue3       = Guid.NewGuid().ToString(),
                FieldValue4       = Guid.NewGuid().ToString(),
                FieldValue5       = Guid.NewGuid().ToString(),
                FieldValue6       = Guid.NewGuid().ToString(),
                FieldValue7       = Guid.NewGuid().ToString(),
                FieldValue8       = Guid.NewGuid().ToString(),
                FieldValue9       = Guid.NewGuid().ToString(),
                FieldValue10      = Guid.NewGuid().ToString(),
                MicrotingUid      = rnd.Next(shortMinValue, shortmaxValue),
                SiteId            = site.Id,
                UnitId            = unit.Id,
                WorkerId          = worker.Id,
                CheckListId       = checklist.Id,
                MicrotingCheckUid = rnd.Next(shortMinValue, shortmaxValue)
            };
            await theCase.Create(dbContext).ConfigureAwait(false);

            uploaded_data uploadedData = new uploaded_data
            {
                Checksum        = Guid.NewGuid().ToString(),
                Extension       = Guid.NewGuid().ToString(),
                Local           = (short)rnd.Next(shortMinValue, shortmaxValue),
                CurrentFile     = Guid.NewGuid().ToString(),
                ExpirationDate  = DateTime.Now,
                FileLocation    = Guid.NewGuid().ToString(),
                FileName        = Guid.NewGuid().ToString(),
                TranscriptionId = rnd.Next(1, 255),
                UploaderId      = rnd.Next(1, 255),
                UploaderType    = Guid.NewGuid().ToString()
            };
            await uploadedData.Create(dbContext).ConfigureAwait(false);

            field_values fieldValue = new field_values
            {
                Accuracy       = Guid.NewGuid().ToString(),
                Altitude       = Guid.NewGuid().ToString(),
                Date           = DateTime.Now,
                Heading        = Guid.NewGuid().ToString(),
                Latitude       = Guid.NewGuid().ToString(),
                Longitude      = Guid.NewGuid().ToString(),
                Value          = Guid.NewGuid().ToString(),
                CaseId         = theCase.Id,
                DoneAt         = DateTime.Now,
                FieldId        = field.Id,
                WorkerId       = worker.Id,
                CheckListId    = checklist.Id,
                UploadedDataId = uploadedData.Id
            };
            await fieldValue.Create(dbContext).ConfigureAwait(false);

            //Act

            DateTime?oldUpdatedAt = fieldValue.UpdatedAt;


            await fieldValue.Delete(dbContext);

            List <field_values>         fieldValues        = dbContext.field_values.AsNoTracking().ToList();
            List <field_value_versions> fieldValueVersions = dbContext.field_value_versions.AsNoTracking().ToList();

            Assert.NotNull(fieldValues);
            Assert.NotNull(fieldValueVersions);

            Assert.AreEqual(1, fieldValues.Count());
            Assert.AreEqual(2, fieldValueVersions.Count());

            Assert.AreEqual(fieldValue.CreatedAt.ToString(), fieldValues[0].CreatedAt.ToString());
            Assert.AreEqual(fieldValue.Version, fieldValues[0].Version);
//            Assert.AreEqual(fieldValue.UpdatedAt.ToString(), fieldValues[0].UpdatedAt.ToString());
            Assert.AreEqual(fieldValues[0].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(fieldValue.Id, fieldValues[0].Id);
            Assert.AreEqual(fieldValue.Accuracy, fieldValues[0].Accuracy);
            Assert.AreEqual(fieldValue.Date.ToString(), fieldValues[0].Date.ToString());
            Assert.AreEqual(fieldValue.Heading, fieldValues[0].Heading);
            Assert.AreEqual(fieldValue.Latitude, fieldValues[0].Latitude);
            Assert.AreEqual(fieldValue.Longitude, fieldValues[0].Longitude);
            Assert.AreEqual(fieldValue.Value, fieldValues[0].Value);
            Assert.AreEqual(fieldValue.CaseId, theCase.Id);
            Assert.AreEqual(fieldValue.DoneAt.ToString(), fieldValues[0].DoneAt.ToString());
            Assert.AreEqual(fieldValue.FieldId, field.Id);
            Assert.AreEqual(fieldValue.WorkerId, worker.Id);
            Assert.AreEqual(fieldValue.CheckListId, checklist.Id);
            Assert.AreEqual(fieldValue.UploadedDataId, uploadedData.Id);

            //Old Version
            Assert.AreEqual(fieldValue.CreatedAt.ToString(), fieldValueVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, fieldValueVersions[0].Version);
//            Assert.AreEqual(oldUpdatedAt.ToString(), fieldValueVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(fieldValueVersions[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(fieldValue.Id, fieldValueVersions[0].FieldId);
            Assert.AreEqual(fieldValue.Accuracy, fieldValueVersions[0].Accuracy);
            Assert.AreEqual(fieldValue.Date.ToString(), fieldValueVersions[0].Date.ToString());
            Assert.AreEqual(fieldValue.Heading, fieldValueVersions[0].Heading);
            Assert.AreEqual(fieldValue.Latitude, fieldValueVersions[0].Latitude);
            Assert.AreEqual(fieldValue.Longitude, fieldValueVersions[0].Longitude);
            Assert.AreEqual(fieldValue.Value, fieldValueVersions[0].Value);
            Assert.AreEqual(theCase.Id, fieldValueVersions[0].CaseId);
            Assert.AreEqual(fieldValue.DoneAt.ToString(), fieldValueVersions[0].DoneAt.ToString());
            Assert.AreEqual(field.Id, fieldValueVersions[0].FieldId);
            Assert.AreEqual(worker.Id, fieldValueVersions[0].WorkerId);
            Assert.AreEqual(checklist.Id, fieldValueVersions[0].CheckListId);
            Assert.AreEqual(uploadedData.Id, fieldValueVersions[0].UploadedDataId);

            //New Version
            Assert.AreEqual(fieldValue.CreatedAt.ToString(), fieldValueVersions[1].CreatedAt.ToString());
            Assert.AreEqual(2, fieldValueVersions[1].Version);
//            Assert.AreEqual(fieldValue.UpdatedAt.ToString(), fieldValueVersions[1].UpdatedAt.ToString());
            Assert.AreEqual(fieldValueVersions[1].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(fieldValue.Id, fieldValueVersions[1].FieldId);
            Assert.AreEqual(fieldValue.Accuracy, fieldValueVersions[1].Accuracy);
            Assert.AreEqual(fieldValue.Date.ToString(), fieldValueVersions[1].Date.ToString());
            Assert.AreEqual(fieldValue.Heading, fieldValueVersions[1].Heading);
            Assert.AreEqual(fieldValue.Latitude, fieldValueVersions[1].Latitude);
            Assert.AreEqual(fieldValue.Longitude, fieldValueVersions[1].Longitude);
            Assert.AreEqual(fieldValue.Value, fieldValueVersions[1].Value);
            Assert.AreEqual(theCase.Id, fieldValueVersions[1].CaseId);
            Assert.AreEqual(fieldValue.DoneAt.ToString(), fieldValueVersions[1].DoneAt.ToString());
            Assert.AreEqual(field.Id, fieldValueVersions[1].FieldId);
            Assert.AreEqual(worker.Id, fieldValueVersions[1].WorkerId);
            Assert.AreEqual(checklist.Id, fieldValueVersions[1].CheckListId);
            Assert.AreEqual(uploadedData.Id, fieldValueVersions[1].UploadedDataId);
        }