public async Task Units_Create_DoesCreate()
        {
            //Arrange

            Random rnd = new Random();


            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),
                Site           = site,
                SiteId         = site.Id,
                Manufacturer   = Guid.NewGuid().ToString(),
                Model          = Guid.NewGuid().ToString(),
                Note           = Guid.NewGuid().ToString(),
                eFormVersion   = Guid.NewGuid().ToString(),
                InSightVersion = Guid.NewGuid().ToString()
            };

            //Act

            await unit.Create(dbContext).ConfigureAwait(false);

            List <units>         units         = dbContext.units.AsNoTracking().ToList();
            List <unit_versions> unitsVersions = dbContext.unit_versions.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(units);
            Assert.NotNull(unitsVersions);

            Assert.AreEqual(1, units.Count());
            Assert.AreEqual(1, unitsVersions.Count());


            Assert.AreEqual(unit.CustomerNo, units[0].CustomerNo);
            Assert.AreEqual(unit.MicrotingUid, units[0].MicrotingUid);
            Assert.AreEqual(unit.OtpCode, units[0].OtpCode);
            Assert.AreEqual(unit.SiteId, site.Id);
            Assert.AreEqual(units[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(unit.CreatedAt.ToString(), units[0].CreatedAt.ToString());
            Assert.AreEqual(unit.Version, units[0].Version);
            Assert.AreEqual(unit.Id, units[0].Id);
//            Assert.AreEqual(unit.UpdatedAt.ToString(), units[0].UpdatedAt.ToString());
            Assert.AreEqual(unit.Model, units[0].Model);
            Assert.AreEqual(unit.Manufacturer, units[0].Manufacturer);
            Assert.AreEqual(unit.eFormVersion, units[0].eFormVersion);
            Assert.AreEqual(unit.InSightVersion, units[0].InSightVersion);
            Assert.AreEqual(unit.Note, units[0].Note);


            //Versions
            Assert.AreEqual(unit.CustomerNo, unitsVersions[0].CustomerNo);
            Assert.AreEqual(unit.MicrotingUid, unitsVersions[0].MicrotingUid);
            Assert.AreEqual(unit.OtpCode, unitsVersions[0].OtpCode);
            Assert.AreEqual(site.Id, unitsVersions[0].SiteId);
            Assert.AreEqual(unitsVersions[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(unit.CreatedAt.ToString(), unitsVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, unitsVersions[0].Version);
            Assert.AreEqual(unit.Id, unitsVersions[0].Id);
//            Assert.AreEqual(unit.UpdatedAt.ToString(), unitsVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(unit.Model, unitsVersions[0].Model);
            Assert.AreEqual(unit.Manufacturer, unitsVersions[0].Manufacturer);
            Assert.AreEqual(unit.eFormVersion, unitsVersions[0].eFormVersion);
            Assert.AreEqual(unit.InSightVersion, unitsVersions[0].InSightVersion);
            Assert.AreEqual(unit.Note, unitsVersions[0].Note);
        }
Exemple #2
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);
        }
        public async Task Units_Update_DoesUpdate()
        {
            //Arrange

            Random rnd = new Random();


            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),
                Site           = site,
                SiteId         = site.Id,
                Manufacturer   = Guid.NewGuid().ToString(),
                Model          = Guid.NewGuid().ToString(),
                Note           = Guid.NewGuid().ToString(),
                eFormVersion   = Guid.NewGuid().ToString(),
                InSightVersion = Guid.NewGuid().ToString()
            };

            await unit.Create(dbContext).ConfigureAwait(false);

            //Act

            int?     oldCustomerNo      = unit.CustomerNo;
            int?     oldMicrotingUid    = unit.MicrotingUid;
            int?     oldOtpCode         = unit.OtpCode;
            int?     oldSiteId          = unit.SiteId;
            DateTime?oldUpdatedAt       = unit.UpdatedAt;
            int?     oldId              = unit.Id;
            string   oldManufacturer    = unit.Manufacturer;
            string   oldModel           = unit.Model;
            string   oldNote            = unit.Note;
            string   unitEFormVersion   = unit.eFormVersion;
            string   unitInSightVersion = unit.InSightVersion;


            unit.CustomerNo   = rnd.Next(1, 255);
            unit.MicrotingUid = rnd.Next(1, 255);
            unit.OtpCode      = rnd.Next(1, 255);

            await unit.Update(dbContext).ConfigureAwait(false);

            List <units>         units         = dbContext.units.AsNoTracking().ToList();
            List <unit_versions> unitsVersions = dbContext.unit_versions.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(units);
            Assert.NotNull(unitsVersions);

            Assert.AreEqual(1, units.Count());
            Assert.AreEqual(2, unitsVersions.Count());

            Assert.AreEqual(unit.CustomerNo, units[0].CustomerNo);
            Assert.AreEqual(unit.MicrotingUid, units[0].MicrotingUid);
            Assert.AreEqual(unit.OtpCode, units[0].OtpCode);
            Assert.AreEqual(unit.SiteId, site.Id);
            Assert.AreEqual(unit.CreatedAt.ToString(), units[0].CreatedAt.ToString());
            Assert.AreEqual(unit.Version, units[0].Version);
//            Assert.AreEqual(unit.UpdatedAt.ToString(), units[0].UpdatedAt.ToString());
            Assert.AreEqual(unit.Id, units[0].Id);
            Assert.AreEqual(unit.Model, units[0].Model);
            Assert.AreEqual(unit.Manufacturer, units[0].Manufacturer);
            Assert.AreEqual(unit.eFormVersion, units[0].eFormVersion);
            Assert.AreEqual(unit.InSightVersion, units[0].InSightVersion);
            Assert.AreEqual(unit.Note, units[0].Note);
            //Version 1 Old Version
            Assert.AreEqual(oldCustomerNo, unitsVersions[0].CustomerNo);
            Assert.AreEqual(oldMicrotingUid, unitsVersions[0].MicrotingUid);
            Assert.AreEqual(oldOtpCode, unitsVersions[0].OtpCode);
            Assert.AreEqual(site.Id, unitsVersions[0].SiteId);
            Assert.AreEqual(unit.CreatedAt.ToString(), unitsVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, unitsVersions[0].Version);
//            Assert.AreEqual(oldUpdatedAt.ToString(), unitsVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(oldId, unitsVersions[0].UnitId);
            Assert.AreEqual(oldModel, unitsVersions[0].Model);
            Assert.AreEqual(oldManufacturer, unitsVersions[0].Manufacturer);
            Assert.AreEqual(unitEFormVersion, unitsVersions[0].eFormVersion);
            Assert.AreEqual(unitInSightVersion, unitsVersions[0].InSightVersion);
            Assert.AreEqual(oldNote, unitsVersions[0].Note);

            //Version 2 Updated Version
            Assert.AreEqual(unit.CustomerNo, unitsVersions[1].CustomerNo);
            Assert.AreEqual(unit.MicrotingUid, unitsVersions[1].MicrotingUid);
            Assert.AreEqual(unit.OtpCode, unitsVersions[1].OtpCode);
            Assert.AreEqual(site.Id, unitsVersions[1].SiteId);
            Assert.AreEqual(unit.CreatedAt.ToString(), unitsVersions[1].CreatedAt.ToString());
            Assert.AreEqual(2, unitsVersions[1].Version);
//            Assert.AreEqual(unit.UpdatedAt.ToString(), unitsVersions[1].UpdatedAt.ToString());
            Assert.AreEqual(unit.Id, unitsVersions[1].UnitId);
            Assert.AreEqual(unit.Model, unitsVersions[1].Model);
            Assert.AreEqual(unit.Manufacturer, unitsVersions[1].Manufacturer);
            Assert.AreEqual(unit.eFormVersion, unitsVersions[1].eFormVersion);
            Assert.AreEqual(unit.InSightVersion, unitsVersions[1].InSightVersion);
            Assert.AreEqual(unit.Note, unitsVersions[1].Note);
        }
        public async Task Answers_Create_DoesCreate()
        {
            //Arrange
            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);

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

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

            languages language = new languages
            {
                Description = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString()
            };
            await language.Create(dbContext).ConfigureAwait(false);

            question_sets questionSet = new question_sets
            {
                Name            = Guid.NewGuid().ToString(),
                Share           = randomBool,
                HasChild        = randomBool,
                PosiblyDeployed = randomBool
            };
            await questionSet.Create(dbContext).ConfigureAwait(false);

            survey_configurations surveyConfiguration = new survey_configurations
            {
                Name          = Guid.NewGuid().ToString(),
                Start         = DateTime.Now,
                Stop          = DateTime.Now,
                TimeOut       = rnd.Next(1, 255),
                TimeToLive    = rnd.Next(1, 255),
                QuestionSetId = questionSet.Id
            };
            await surveyConfiguration.Create(dbContext).ConfigureAwait(false);

            answers answer = new answers
            {
                AnswerDuration        = rnd.Next(1, 255),
                FinishedAt            = DateTime.Now,
                LanguageId            = language.Id,
                Language              = language,
                SiteId                = site.Id,
                UnitId                = unit.Id,
                QuestionSetId         = questionSet.Id,
                SurveyConfigurationId = surveyConfiguration.Id,
                TimeZone              = Guid.NewGuid().ToString(),
                UtcAdjusted           = randomBool
            };

            //Act

            await answer.Create(dbContext).ConfigureAwait(false);

            List <answers>         answers        = dbContext.answers.AsNoTracking().ToList();
            List <answer_versions> answerVersions = dbContext.answer_versions.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(answers);
            Assert.NotNull(answerVersions);

            Assert.AreEqual(1, answers.Count());
            Assert.AreEqual(1, answerVersions.Count());

            Assert.AreEqual(answer.CreatedAt.ToString(), answers[0].CreatedAt.ToString());
            Assert.AreEqual(answer.Version, answers[0].Version);
//            Assert.AreEqual(answer.UpdatedAt.ToString(), answers[0].UpdatedAt.ToString());
            Assert.AreEqual(answers[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(answer.Id, answers[0].Id);
            Assert.AreEqual(answer.AnswerDuration, answers[0].AnswerDuration);
            Assert.AreEqual(answer.FinishedAt.ToString(), answers[0].FinishedAt.ToString());
            Assert.AreEqual(answer.LanguageId, language.Id);
            Assert.AreEqual(answer.SiteId, site.Id);
            Assert.AreEqual(answer.TimeZone, answers[0].TimeZone);
            Assert.AreEqual(answer.UnitId, unit.Id);
            Assert.AreEqual(answer.UtcAdjusted, answers[0].UtcAdjusted);
            Assert.AreEqual(answer.QuestionSetId, questionSet.Id);
            Assert.AreEqual(answer.SurveyConfigurationId, surveyConfiguration.Id);


            //Version 1
            Assert.AreEqual(answer.CreatedAt.ToString(), answerVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, answerVersions[0].Version);
//            Assert.AreEqual(answer.UpdatedAt.ToString(), answerVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(answerVersions[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(answer.Id, answerVersions[0].AnswerId);
            Assert.AreEqual(answer.AnswerDuration, answerVersions[0].AnswerDuration);
            Assert.AreEqual(answer.FinishedAt.ToString(), answerVersions[0].FinishedAt.ToString());
            Assert.AreEqual(language.Id, answerVersions[0].LanguageId);
            Assert.AreEqual(site.Id, answerVersions[0].SiteId);
            Assert.AreEqual(answer.TimeZone, answerVersions[0].TimeZone);
            Assert.AreEqual(unit.Id, answerVersions[0].UnitId);
            Assert.AreEqual(answer.UtcAdjusted, answerVersions[0].UtcAdjusted);
            Assert.AreEqual(questionSet.Id, answerVersions[0].QuestionSetId);
            Assert.AreEqual(surveyConfiguration.Id, answerVersions[0].SurveyConfigurationId);
        }
        public async Task Cases_Delete_DoesSetWorkflowStateToRemoved()
        {
            //Arrange

            Random rnd = new Random();

            short shortMinValue = Int16.MinValue;
            short shortmaxValue = Int16.MaxValue;

            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);

            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);

            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);

            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);


            //Act

            DateTime?oldUpdatedAt = theCase.UpdatedAt;

            await theCase.Delete(dbContext);

            List <cases>         cases        = dbContext.cases.AsNoTracking().ToList();
            List <case_versions> caseVersions = dbContext.case_versions.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(cases);
            Assert.NotNull(caseVersions);

            Assert.AreEqual(1, cases.Count());
            Assert.AreEqual(2, caseVersions.Count());

            Assert.AreEqual(theCase.CreatedAt.ToString(), cases[0].CreatedAt.ToString());
            Assert.AreEqual(theCase.Version, cases[0].Version);
//            Assert.AreEqual(theCase.UpdatedAt.ToString(), cases[0].UpdatedAt.ToString());
            Assert.AreEqual(cases[0].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(theCase.Id, cases[0].Id);
            Assert.AreEqual(theCase.Custom, cases[0].Custom);
            Assert.AreEqual(theCase.SiteId, site.Id);
            Assert.AreEqual(theCase.Status, cases[0].Status);
            Assert.AreEqual(theCase.Type, cases[0].Type);
            Assert.AreEqual(theCase.UnitId, unit.Id);
            Assert.AreEqual(theCase.WorkerId, worker.Id);
            Assert.AreEqual(theCase.CaseUid, cases[0].CaseUid);
            Assert.AreEqual(theCase.CheckListId, checklist.Id);
            Assert.AreEqual(theCase.DoneAt.ToString(), cases[0].DoneAt.ToString());
            Assert.AreEqual(theCase.FieldValue1, cases[0].FieldValue1);
            Assert.AreEqual(theCase.FieldValue2, cases[0].FieldValue2);
            Assert.AreEqual(theCase.FieldValue3, cases[0].FieldValue3);
            Assert.AreEqual(theCase.FieldValue4, cases[0].FieldValue4);
            Assert.AreEqual(theCase.FieldValue5, cases[0].FieldValue5);
            Assert.AreEqual(theCase.FieldValue6, cases[0].FieldValue6);
            Assert.AreEqual(theCase.FieldValue7, cases[0].FieldValue7);
            Assert.AreEqual(theCase.FieldValue8, cases[0].FieldValue8);
            Assert.AreEqual(theCase.FieldValue9, cases[0].FieldValue9);
            Assert.AreEqual(theCase.FieldValue10, cases[0].FieldValue10);
            Assert.AreEqual(theCase.MicrotingUid, cases[0].MicrotingUid);
            Assert.AreEqual(theCase.MicrotingCheckUid, cases[0].MicrotingCheckUid);

            //Old Version
            Assert.AreEqual(theCase.CreatedAt.ToString(), caseVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, caseVersions[0].Version);
//            Assert.AreEqual(oldUpdatedAt.ToString(), caseVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(caseVersions[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(theCase.Id, caseVersions[0].CaseId);
            Assert.AreEqual(theCase.Custom, caseVersions[0].Custom);
            Assert.AreEqual(site.Id, caseVersions[0].SiteId);
            Assert.AreEqual(theCase.Status, caseVersions[0].Status);
            Assert.AreEqual(theCase.Type, caseVersions[0].Type);
            Assert.AreEqual(unit.Id, caseVersions[0].UnitId);
            Assert.AreEqual(worker.Id, caseVersions[0].WorkerId);
            Assert.AreEqual(theCase.CaseUid, caseVersions[0].CaseUid);
            Assert.AreEqual(checklist.Id, caseVersions[0].CheckListId);
            Assert.AreEqual(theCase.DoneAt.ToString(), caseVersions[0].DoneAt.ToString());
            Assert.AreEqual(theCase.FieldValue1, caseVersions[0].FieldValue1);
            Assert.AreEqual(theCase.FieldValue2, caseVersions[0].FieldValue2);
            Assert.AreEqual(theCase.FieldValue3, caseVersions[0].FieldValue3);
            Assert.AreEqual(theCase.FieldValue4, caseVersions[0].FieldValue4);
            Assert.AreEqual(theCase.FieldValue5, caseVersions[0].FieldValue5);
            Assert.AreEqual(theCase.FieldValue6, caseVersions[0].FieldValue6);
            Assert.AreEqual(theCase.FieldValue7, caseVersions[0].FieldValue7);
            Assert.AreEqual(theCase.FieldValue8, caseVersions[0].FieldValue8);
            Assert.AreEqual(theCase.FieldValue9, caseVersions[0].FieldValue9);
            Assert.AreEqual(theCase.FieldValue10, caseVersions[0].FieldValue10);
            Assert.AreEqual(theCase.MicrotingUid, caseVersions[0].MicrotingUid);
            Assert.AreEqual(theCase.MicrotingCheckUid, caseVersions[0].MicrotingCheckUid);

            //New Version
            Assert.AreEqual(theCase.CreatedAt.ToString(), caseVersions[1].CreatedAt.ToString());
            Assert.AreEqual(2, cases[0].Version);
//            Assert.AreEqual(theCase.UpdatedAt.ToString(), caseVersions[1].UpdatedAt.ToString());
            Assert.AreEqual(caseVersions[1].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(theCase.Id, caseVersions[1].CaseId);
            Assert.AreEqual(theCase.Custom, caseVersions[1].Custom);
            Assert.AreEqual(site.Id, caseVersions[1].SiteId);
            Assert.AreEqual(theCase.Status, caseVersions[1].Status);
            Assert.AreEqual(theCase.Type, caseVersions[1].Type);
            Assert.AreEqual(unit.Id, caseVersions[1].UnitId);
            Assert.AreEqual(worker.Id, caseVersions[1].WorkerId);
            Assert.AreEqual(theCase.CaseUid, caseVersions[1].CaseUid);
            Assert.AreEqual(checklist.Id, caseVersions[1].CheckListId);
            Assert.AreEqual(theCase.DoneAt.ToString(), caseVersions[1].DoneAt.ToString());
            Assert.AreEqual(theCase.FieldValue1, caseVersions[1].FieldValue1);
            Assert.AreEqual(theCase.FieldValue2, caseVersions[1].FieldValue2);
            Assert.AreEqual(theCase.FieldValue3, caseVersions[1].FieldValue3);
            Assert.AreEqual(theCase.FieldValue4, caseVersions[1].FieldValue4);
            Assert.AreEqual(theCase.FieldValue5, caseVersions[1].FieldValue5);
            Assert.AreEqual(theCase.FieldValue6, caseVersions[1].FieldValue6);
            Assert.AreEqual(theCase.FieldValue7, caseVersions[1].FieldValue7);
            Assert.AreEqual(theCase.FieldValue8, caseVersions[1].FieldValue8);
            Assert.AreEqual(theCase.FieldValue9, caseVersions[1].FieldValue9);
            Assert.AreEqual(theCase.FieldValue10, caseVersions[1].FieldValue10);
            Assert.AreEqual(theCase.MicrotingUid, caseVersions[1].MicrotingUid);
            Assert.AreEqual(theCase.MicrotingCheckUid, caseVersions[1].MicrotingCheckUid);
        }
Exemple #6
0
        public async Task AnswerValues_Delete_DoesSetWorkflowStateToRemoved()
        {
            //Arrange

            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);

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

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

            languages language = new languages
            {
                Description = Guid.NewGuid().ToString(),
                Name        = Guid.NewGuid().ToString()
            };
            await language.Create(dbContext).ConfigureAwait(false);

            question_sets questionSet = new question_sets
            {
                Name            = Guid.NewGuid().ToString(),
                Share           = randomBool,
                HasChild        = randomBool,
                PosiblyDeployed = randomBool
            };
            await questionSet.Create(dbContext).ConfigureAwait(false);

            survey_configurations surveyConfiguration = new survey_configurations
            {
                Name          = Guid.NewGuid().ToString(),
                Start         = DateTime.Now,
                Stop          = DateTime.Now,
                TimeOut       = rnd.Next(1, 255),
                TimeToLive    = rnd.Next(1, 255),
                QuestionSetId = questionSet.Id
            };
            await surveyConfiguration.Create(dbContext).ConfigureAwait(false);

            answers answer = new answers
            {
                AnswerDuration        = rnd.Next(1, 255),
                FinishedAt            = DateTime.Now,
                LanguageId            = language.Id,
                SiteId                = site.Id,
                SurveyConfiguration   = surveyConfiguration,
                TimeZone              = Guid.NewGuid().ToString(),
                UnitId                = unit.Id,
                UtcAdjusted           = randomBool,
                QuestionSetId         = questionSet.Id,
                SurveyConfigurationId = surveyConfiguration.Id
            };
            await answer.Create(dbContext).ConfigureAwait(false);

            questions question = new questions
            {
                Image                = randomBool,
                Maximum              = rnd.Next(1, 255),
                Minimum              = rnd.Next(1, 255),
                Prioritised          = randomBool,
                Type                 = Guid.NewGuid().ToString(),
                FontSize             = Guid.NewGuid().ToString(),
                ImagePosition        = Guid.NewGuid().ToString(),
                MaxDuration          = rnd.Next(1, 255),
                MinDuration          = rnd.Next(1, 255),
                QuestionIndex        = rnd.Next(1, 255),
                QuestionType         = Guid.NewGuid().ToString(),
                RefId                = rnd.Next(1, 255),
                ValidDisplay         = randomBool,
                BackButtonEnabled    = randomBool,
                ContinuousQuestionId = rnd.Next(1, 255),
                QuestionSetId        = questionSet.Id
            };
            await question.Create(dbContext).ConfigureAwait(false);

            options option = new options
            {
                Weight             = rnd.Next(1, 255),
                OptionsIndex       = rnd.Next(1, 255),
                QuestionId         = question.Id,
                WeightValue        = rnd.Next(1, 255),
                ContinuousOptionId = rnd.Next(1, 255)
            };
            await option.Create(dbContext).ConfigureAwait(false);

            questions questionForAnswerValue = new questions
            {
                Image                = randomBool,
                Maximum              = rnd.Next(1, 255),
                Minimum              = rnd.Next(1, 255),
                Prioritised          = randomBool,
                Type                 = Guid.NewGuid().ToString(),
                FontSize             = Guid.NewGuid().ToString(),
                ImagePosition        = Guid.NewGuid().ToString(),
                MaxDuration          = rnd.Next(1, 255),
                MinDuration          = rnd.Next(1, 255),
                QuestionIndex        = rnd.Next(1, 255),
                QuestionType         = Guid.NewGuid().ToString(),
                RefId                = rnd.Next(1, 255),
                ValidDisplay         = randomBool,
                BackButtonEnabled    = randomBool,
                ContinuousQuestionId = rnd.Next(1, 255),
                QuestionSetId        = questionSet.Id
            };
            await questionForAnswerValue.Create(dbContext).ConfigureAwait(false);

            answer_values answerValue = new answer_values
            {
                Value      = rnd.Next(1, 255).ToString(),
                AnswerId   = answer.Id,
                OptionId   = option.Id,
                QuestionId = question.Id
            };
            await answerValue.Create(dbContext).ConfigureAwait(false);

            //Act

            DateTime?oldUpdatedAt = answerValue.UpdatedAt;

            await answerValue.Delete(dbContext);


            List <answer_values>         answerValues        = dbContext.answer_values.AsNoTracking().ToList();
            List <answer_value_versions> answerValueVersions = dbContext.answer_value_versions.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(answerValues);
            Assert.NotNull(answerValueVersions);

            Assert.AreEqual(1, answerValues.Count());
            Assert.AreEqual(2, answerValueVersions.Count());

            Assert.AreEqual(answerValue.CreatedAt.ToString(), answerValues[0].CreatedAt.ToString());
            Assert.AreEqual(answerValue.Version, answerValues[0].Version);
//             Assert.AreEqual(answerValue.UpdatedAt.ToString(), answerValues[0].UpdatedAt.ToString());
            Assert.AreEqual(answerValues[0].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(answerValue.Value, answerValues[0].Value);
            Assert.AreEqual(answerValue.Id, answerValues[0].Id);
            Assert.AreEqual(answerValue.AnswerId, answer.Id);
            Assert.AreEqual(answerValue.OptionId, option.Id);
            Assert.AreEqual(answerValue.QuestionId, question.Id);

            //Old Version
            Assert.AreEqual(answerValue.CreatedAt.ToString(), answerValueVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, answerValueVersions[0].Version);
//             Assert.AreEqual(oldUpdatedAt.ToString(), answerValueVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(answerValueVersions[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(answerValue.Id, answerValueVersions[0].AnswerValueId);
            Assert.AreEqual(answerValue.Value, answerValueVersions[0].Value);
            Assert.AreEqual(answer.Id, answerValueVersions[0].AnswerId);
            Assert.AreEqual(option.Id, answerValueVersions[0].OptionId);
            Assert.AreEqual(question.Id, answerValueVersions[0].QuestionId);

            //New Version
            Assert.AreEqual(answerValue.CreatedAt.ToString(), answerValueVersions[1].CreatedAt.ToString());
            Assert.AreEqual(2, answerValueVersions[1].Version);
//             Assert.AreEqual(answerValue.UpdatedAt.ToString(), answerValueVersions[1].UpdatedAt.ToString());
            Assert.AreEqual(answerValueVersions[1].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(answerValue.Id, answerValueVersions[1].AnswerValueId);
            Assert.AreEqual(answerValue.Value, answerValueVersions[1].Value);
            Assert.AreEqual(answer.Id, answerValueVersions[1].AnswerId);
            Assert.AreEqual(option.Id, answerValueVersions[1].OptionId);
            Assert.AreEqual(question.Id, answerValueVersions[1].QuestionId);
        }
        public static async Task Main()
        {
            _core = new Core();

            var connection = _core
                             .StartSqlOnly(
                "host= localhost;Database=420_SDK;user = root;port=3306;Convert Zero Datetime = true;SslMode=none;")
                             .Result;

            MicrotingDbContext dbContext = _core.dbContextHelper.GetDbContext();

            question_sets questionSets = new question_sets
            {
                Name = "Test-Set"
            };

            if (dbContext.question_sets.Count(x => x.Name == questionSets.Name) != 1)
            {
                await questionSets.Create(dbContext);
            }

            languages language = new languages
            {
                Description = "Description",
                Name        = "Danish"
            };

            if (dbContext.languages.Count(x => x.Name == "da-DK") != 1)
            {
                await language.Create(dbContext);
            }

            languages dbLanguage = await dbContext.languages.FirstOrDefaultAsync(x => x.Name == language.Name);

            question_sets dbQuestionSets = await dbContext.question_sets.FirstOrDefaultAsync(x => x.Name == questionSets.Name);

            string[] questionNames = new[] { "Q1", "Q2", "Q3", "Q4", "Q5", "Q6", "Q7", "Q8", "Q9", "Q10", "Q11", "Q12", "Q13" };
            //                                13    14    15    16    17    18    19    20    21    22    23    24
            List <KeyValuePair <int, questions> > questionIds = new List <KeyValuePair <int, questions> >();

            int qi = 13;

            foreach (var questionName in questionNames)
            {
                if (questionName != "Q13" && questionName != "Q1")
                {
                    var questionTranslation =
                        dbContext.QuestionTranslations.SingleOrDefault(x => x.Name == questionName);

                    if (questionTranslation == null)
                    {
                        questions question = new questions()
                        {
                            QuestionSetId = dbQuestionSets.Id,
                            QuestionType  = Constants.QuestionTypes.Smiley2
                        };
                        await question.Create(dbContext);

                        KeyValuePair <int, questions> kvp = new KeyValuePair <int, questions>(qi, question);
                        questionIds.Add(kvp);

                        questionTranslation = new question_translations()
                        {
                            Name       = questionName,
                            QuestionId = question.Id,
                            LanguageId = dbLanguage.Id
                        };
                        await questionTranslation.Create(dbContext);
                    }
                    else
                    {
                        KeyValuePair <int, questions> kvp = new KeyValuePair <int, questions>(qi, questionTranslation.Question);
                        questionIds.Add(kvp);
                    }
                }
                else
                {
                    var questionTranslation =
                        dbContext.QuestionTranslations.SingleOrDefault(x => x.Name == questionName);

                    if (questionTranslation == null)
                    {
                        questions question = new questions()
                        {
                            QuestionSetId = dbQuestionSets.Id,
                            QuestionType  = questionName == "Q1" ? Constants.QuestionTypes.List : Constants.QuestionTypes.Multi
                        };
                        await question.Create(dbContext);

                        questionTranslation = new question_translations()
                        {
                            Name       = questionName,
                            QuestionId = question.Id,
                            LanguageId = dbLanguage.Id
                        };
                        await questionTranslation.Create(dbContext);

                        string[] questionOptions;
                        if (questionName == "Q1")
                        {
                            questionOptions = new[] { "Ja", "Nej" };
                        }
                        else
                        {
                            questionOptions = new[] { "1", "2", "3", "4", "5" };
                        }


                        foreach (string questionOption in questionOptions)
                        {
                            options option = new options()
                            {
                                QuestionId  = question.Id,
                                Weight      = 1,
                                WeightValue = 1
                            };
                            await option.Create(dbContext);

                            option_translations optionTranslation = new option_translations()
                            {
                                OptionId   = option.Id,
                                Name       = questionOption,
                                LanguageId = dbLanguage.Id
                            };

                            await optionTranslation.Create(dbContext);
                        }

                        KeyValuePair <int, questions> kvp = new KeyValuePair <int, questions>(qi, question);
                        questionIds.Add(kvp);
                    }
                    else
                    {
                        KeyValuePair <int, questions> kvp = new KeyValuePair <int, questions>(qi, questionTranslation.Question);
                        questionIds.Add(kvp);
                    }
                }
                qi++;
            }

            // Q13 with options

            // KeyValuePair<int, questions> kvp = new KeyValuePair<int, questions>(qi, questionTranslation.Question);
            // questionIds.Add(kvp);

            survey_configurations surveyConfiguration = new survey_configurations
            {
                QuestionSetId = dbQuestionSets.Id,
                Name          = "Configuartion 1"
            };

            if (dbContext.survey_configurations.Count(x => x.Name == surveyConfiguration.Name) != 1)
            {
                await surveyConfiguration.Create(dbContext);
            }

            survey_configurations dbSurveyConfiguration =
                await dbContext.survey_configurations.FirstOrDefaultAsync(x => x.Name == surveyConfiguration.Name);

            // dbContext.question_sets questionSets = new question_sets();
            Random rnd      = new Random();
            var    document = @"/home/microting/Documents/workspace/microting/ExcelReadManipPOC/Test-data.xlsx";

            using (FileStream fs = new FileStream(document, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (SpreadsheetDocument doc = SpreadsheetDocument.Open(fs, false))
                {
                    S sheets = doc.WorkbookPart.Workbook.Sheets;

                    foreach (E sheet in sheets)
                    {
                        foreach (A attr in sheet.GetAttributes())
                        {
                            Console.WriteLine("{0}: {1}", attr.LocalName, attr.Value);
                        }
                    }

                    WorkbookPart  workbookPart  = doc.WorkbookPart;
                    WorksheetPart worksheetPart = GetWorksheetFromSheetName(workbookPart, "Senge_voksen");

                    var sheet1 = worksheetPart.Worksheet;


                    // Console.WriteLine(sheet1);


                    var cells = sheet1.Descendants <Cell>();
                    var rows  = sheet1.Descendants <Row>();
                    var cols  = sheet1.Descendants <Column>();

                    List <Column> columns = cols.ToList();

                    string text;
                    var    rows1       = sheet1.GetFirstChild <SheetData>().Elements <Row>();
                    int    i           = 0;
                    var    stringTable = workbookPart.GetPartsOfType <SharedStringTablePart>()
                                         .FirstOrDefault();
                    List <KeyValuePair <string, sites> > localSites = new List <KeyValuePair <string, sites> >();
                    List <KeyValuePair <string, units> > localUnits = new List <KeyValuePair <string, units> >();
                    var languageId = dbContext.languages.SingleOrDefault(x => x.Name == "da-DK");
                    // List<sites> localSites = new List<sites>();
                    // List<units> localUnits = new List<units>();
                    foreach (var row in rows1)
                    {
                        if (i > 0 && i < 553)
                        {
                            var cells1 = row.Elements <Cell>();

                            int         cellNumber   = 0;
                            answers     answer       = null;
                            List <Cell> theCells     = cells1.ToList();
                            var         microtingUid = int.Parse(theCells[0].CellValue.Text);
                            var         duration     = int.Parse(theCells[1].CellValue.Text);
                            var         date         = stringTable.SharedStringTable.ElementAt(
                                int.Parse(theCells[2].CellValue.Text)).InnerText;
                            var time = stringTable.SharedStringTable.ElementAt(
                                int.Parse(theCells[7].CellValue.Text)).InnerText;

                            DateTime dateOfDoing = DateTime.ParseExact($"{date} {time}", "dd-MM-yyyy HH:mm:ss", null);

                            var location = stringTable.SharedStringTable.ElementAt(
                                int.Parse(theCells[9].CellValue.Text)).InnerText;

                            int?sdkSiteId = null;
                            int?sdkUnitId = null;

                            if (localSites.Any(x => x.Key == location))
                            {
                                sdkSiteId = localSites.First(x => x.Key == location).Value.Id;
                            }
                            else
                            {
                                var lookupSite = dbContext.sites.SingleOrDefault(x => x.Name == location);
                                if (lookupSite != null)
                                {
                                    KeyValuePair <string, sites> pair = new KeyValuePair <string, sites>(location, lookupSite);
                                    localSites.Add(pair);
                                    sdkSiteId = lookupSite.Id;
                                }
                                else
                                {
                                    sites site = new sites()
                                    {
                                        Name         = location,
                                        MicrotingUid = rnd.Next(1, 999999)
                                    };
                                    await site.Create(dbContext);

                                    KeyValuePair <string, sites> pair = new KeyValuePair <string, sites>(location, site);
                                    localSites.Add(pair);
                                    sdkSiteId = site.Id;
                                }
                            }

                            var unitString = theCells[11].CellValue.Text;
                            if (localUnits.Any(x => x.Key == unitString))
                            {
                                sdkUnitId = localUnits.First(x => x.Key == unitString).Value.Id;
                            }
                            else
                            {
                                var lookupUnit = dbContext.units.SingleOrDefault(x => x.MicrotingUid.ToString() == unitString);

                                if (lookupUnit != null)
                                {
                                    KeyValuePair <string, units> pair = new KeyValuePair <string, units>(unitString, lookupUnit);
                                    localUnits.Add(pair);
                                    sdkUnitId = lookupUnit.Id;
                                }
                                else
                                {
                                    units unit = new units()
                                    {
                                        MicrotingUid = int.Parse(unitString),
                                        SiteId       = sdkSiteId
                                    };
                                    await unit.Create(dbContext);

                                    KeyValuePair <string, units> pair = new KeyValuePair <string, units>(unitString, unit);
                                    localUnits.Add(pair);
                                    sdkUnitId = unit.Id;
                                }
                            }



                            answer = dbContext.answers.SingleOrDefault(x =>
                                                                       x.MicrotingUid == microtingUid);
                            if (answer == null)
                            {
                                answer = new answers()
                                {
                                    AnswerDuration        = duration,
                                    UnitId                = (int)sdkUnitId,
                                    SiteId                = (int)sdkSiteId,
                                    MicrotingUid          = microtingUid,
                                    FinishedAt            = dateOfDoing,
                                    LanguageId            = dbLanguage.Id,
                                    QuestionSetId         = dbQuestionSets.Id,
                                    SurveyConfigurationId = dbSurveyConfiguration.Id
                                };
                                await answer.Create(dbContext);
                            }

                            foreach (var cell in cells1)
                            {
                                if (cell == null)
                                {
                                    Console.WriteLine("We got a null here");
                                }
                                else
                                {
                                    if (cellNumber > 12)
                                    {
                                        int questionLookupId = cellNumber;
                                        if (cellNumber > 25)
                                        {
                                            questionLookupId = 25;
                                        }

                                        int?lookupOptionId = null;
                                        if (cell.DataType != null)
                                        {
                                            //     if (cell.DataType.Value == CellValues.Number)
                                            //     {
                                            //         lookupOptionId = questionIds
                                            //             .First(x => x.Key == questionLookupId).Value.Options
                                            //             .SingleOrDefault(x => x.WeightValue == int.Parse(cell.CellValue.Text)).Id;
                                            if (cell.DataType.Value == CellValues.SharedString)
                                            {
                                                //         if (questionLookupId != 25)
                                                //         {
                                                foreach (options option in questionIds
                                                         .First(x => x.Key == questionLookupId).Value.Options)
                                                {
                                                    text = stringTable.SharedStringTable.ElementAt(
                                                        int.Parse(cell.CellValue.Text)).InnerText;

                                                    var r = option.OptionTranslationses.SingleOrDefault(x =>
                                                                                                        x.Name == text);
                                                    if (r != null)
                                                    {
                                                        lookupOptionId = r.OptionId;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (cellNumber > 13 && cellNumber < 25)
                                            {
                                                if (cell.CellValue != null)
                                                {
                                                    lookupOptionId = questionIds
                                                                     .First(x => x.Key == questionLookupId).Value.Options
                                                                     .SingleOrDefault(x => x.WeightValue == int.Parse(cell.CellValue.Text)).Id;
                                                }
                                            }
                                            else
                                            {
                                                switch (cellNumber)
                                                {
                                                case 25:
                                                    lookupOptionId = questionIds
                                                                     .First(x => x.Key == questionLookupId).Value.Options
                                                                     .ToList()[0].Id;
                                                    break;

                                                case 26:
                                                    lookupOptionId = questionIds
                                                                     .First(x => x.Key == questionLookupId).Value.Options
                                                                     .ToList()[1].Id;
                                                    break;

                                                case 27:
                                                    lookupOptionId = questionIds
                                                                     .First(x => x.Key == questionLookupId).Value.Options
                                                                     .ToList()[2].Id;
                                                    break;

                                                case 28:
                                                    lookupOptionId = questionIds
                                                                     .First(x => x.Key == questionLookupId).Value.Options
                                                                     .ToList()[3].Id;
                                                    break;

                                                case 29:
                                                    lookupOptionId = questionIds
                                                                     .First(x => x.Key == questionLookupId).Value.Options
                                                                     .ToList()[4].Id;
                                                    break;
                                                }
                                            }
                                        }

                                        //         }
                                        //         else
                                        //         {
                                        //             if (questionLookupId == 25)
                                        //             {
                                        //                 lookupOptionId = questionIds.First(x => x.Key == questionLookupId)
                                        //                     .Value.Options.ToList()[cellNumber - 25].Id;
                                        //             }
                                        //         }
                                        //     }
                                        // }
                                        // else
                                        // {
                                        //     lookupOptionId = questionIds
                                        //         .First(x => x.Key == questionLookupId).Value.Options
                                        //         .SingleOrDefault(x => x.WeightValue == int.Parse(cell.CellValue.Text)).Id;
                                        // }
                                        //
                                        answer_values answerValue = null;
                                        if (lookupOptionId != null)
                                        {
                                            answerValue = dbContext.answer_values
                                                          .SingleOrDefault(x
                                                                           => x.AnswerId == answer.Id &&
                                                                           x.QuestionId == questionIds.First(y
                                                                                                             => y.Key == questionLookupId).Value.Id &&
                                                                           x.OptionId == lookupOptionId);
                                        }
                                        else
                                        {
                                            answerValue = dbContext.answer_values
                                                          .SingleOrDefault(x
                                                                           => x.AnswerId == answer.Id &&
                                                                           x.QuestionId == questionIds.First(y
                                                                                                             => y.Key == questionLookupId).Value.Id);
                                        }

                                        if (answerValue == null)
                                        {
                                            answerValue = new answer_values()
                                            {
                                                AnswerId   = answer.Id,
                                                QuestionId = questionIds.First(x => x.Key == questionLookupId).Value.Id
                                            };

                                            if (cell.DataType != null)
                                            {
                                                if (cell.DataType.Value == CellValues.SharedString)
                                                {
                                                    if (stringTable != null)
                                                    {
                                                        text = stringTable.SharedStringTable.ElementAt(
                                                            int.Parse(cell.CellValue.Text)).InnerText;
                                                        // Console.WriteLine(text + " ");
                                                        int optionId = 0;
                                                        foreach (options option in questionIds
                                                                 .First(x => x.Key == questionLookupId).Value.Options)
                                                        {
                                                            var r = option.OptionTranslationses.SingleOrDefault(x => x.Name == text);
                                                            if (r != null)
                                                            {
                                                                optionId = r.OptionId;
                                                            }
                                                        }
                                                        answerValue.Value      = text;
                                                        answerValue.OptionId   = optionId;
                                                        answerValue.QuestionId = questionIds
                                                                                 .First(x => x.Key == questionLookupId).Value.Id;
                                                        await answerValue.Create(dbContext);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (cellNumber > 13 && cellNumber < 25)
                                                {
                                                    if (cell.CellValue != null)
                                                    {
                                                        text = cell.CellValue.Text;

                                                        answerValue.Value      = text;
                                                        answerValue.QuestionId = questionIds
                                                                                 .First(x => x.Key == questionLookupId).Value.Id;
                                                        answerValue.OptionId = questionIds
                                                                               .First(x => x.Key == questionLookupId).Value.Options
                                                                               .SingleOrDefault(x => x.WeightValue == int.Parse(text)).Id;
                                                        await answerValue.Create(dbContext);

                                                        // Console.WriteLine(cell.CellValue.Text);
                                                    }
                                                }
                                                else
                                                {
                                                    if (cell.CellValue != null)
                                                    {
                                                        if (int.Parse(cell.CellValue.Text) == 1)
                                                        {
                                                            answerValue.Value      = "1";
                                                            answerValue.QuestionId = questionIds
                                                                                     .First(x => x.Key == questionLookupId).Value.Id;
                                                            switch (cellNumber)
                                                            {
                                                            case 25:
                                                                answerValue.OptionId = questionIds
                                                                                       .First(x => x.Key == questionLookupId).Value.Options.ToList()[0].Id;
                                                                break;

                                                            case 26:
                                                                answerValue.OptionId = questionIds
                                                                                       .First(x => x.Key == questionLookupId).Value.Options.ToList()[1].Id;
                                                                break;

                                                            case 27:
                                                                answerValue.OptionId = questionIds
                                                                                       .First(x => x.Key == questionLookupId).Value.Options.ToList()[2].Id;
                                                                break;

                                                            case 28:
                                                                answerValue.OptionId = questionIds
                                                                                       .First(x => x.Key == questionLookupId).Value.Options.ToList()[3].Id;
                                                                break;

                                                            case 29:
                                                                answerValue.OptionId = questionIds
                                                                                       .First(x => x.Key == questionLookupId).Value.Options.ToList()[4].Id;
                                                                break;
                                                            }

                                                            await answerValue.Create(dbContext);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                cellNumber++;
                            }
                        }
                        Console.WriteLine($"ROW {i}");
                        i++;
                    }
                }
            }
            // Q1
            int q1Id           = 1;
            int q2Id           = 2;
            int q3Id           = 3;
            int q4Id           = 4;
            int q5Id           = 5;
            int q6Id           = 6;
            int q7Id           = 7;
            int q8Id           = 8;
            int q9Id           = 9;
            int q10Id          = 10;
            int q11Id          = 11;
            int q12Id          = 12;
            int q13Id          = 13;
            int optionJaId     = 1;
            int optionNejId    = 2;
            int option100q2Id  = 3;
            int option75q2Id   = 4;
            int option50q2Id   = 5;
            int option25q2Id   = 6;
            int option0q2Id    = 7;
            int option999q2Id  = 8;
            int option100q3Id  = 9;
            int option75q3Id   = 10;
            int option50q3Id   = 11;
            int option25q3Id   = 12;
            int option0q3Id    = 13;
            int option999q3Id  = 14;
            int option100q4Id  = 15;
            int option75q4Id   = 16;
            int option50q4Id   = 17;
            int option25q4Id   = 18;
            int option0q4Id    = 19;
            int option999q4Id  = 20;
            int option100q5Id  = 21;
            int option75q5Id   = 22;
            int option50q5Id   = 23;
            int option25q5Id   = 24;
            int option0q5Id    = 25;
            int option999q5Id  = 26;
            int option100q6Id  = 27;
            int option75q6Id   = 28;
            int option50q6Id   = 29;
            int option25q6Id   = 30;
            int option0q6Id    = 31;
            int option999q6Id  = 32;
            int option100q7Id  = 33;
            int option75q7Id   = 34;
            int option50q7Id   = 35;
            int option25q7Id   = 36;
            int option0q7Id    = 37;
            int option999q7Id  = 38;
            int option100q8Id  = 39;
            int option75q8Id   = 40;
            int option50q8Id   = 41;
            int option25q8Id   = 42;
            int option0q8Id    = 43;
            int option999q8Id  = 44;
            int option100q9Id  = 45;
            int option75q9Id   = 46;
            int option50q9Id   = 47;
            int option25q9Id   = 48;
            int option0q9Id    = 49;
            int option999q9Id  = 50;
            int option100q10Id = 51;
            int option75q10Id  = 52;
            int option50q10Id  = 53;
            int option25q10Id  = 54;
            int option0q10Id   = 55;
            int option999q10Id = 56;
            int option100q11Id = 57;
            int option75q11Id  = 58;
            int option50q11Id  = 59;
            int option25q11Id  = 60;
            int option0q11Id   = 61;
            int option999q11Id = 62;
            int option100q12Id = 63;
            int option75q12Id  = 64;
            int option50q12Id  = 65;
            int option25q12Id  = 66;
            int option0q12Id   = 67;
            int option999q12Id = 68;
            int optionq13_1Id  = 69;
            int optionq13_2Id  = 70;
            int optionq13_3Id  = 71;
            int optionq13_4Id  = 72;
            int optionq13_5Id  = 73;

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == optionJaId) == 419);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == optionNejId) == 133);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q1Id) == 552);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q2Id) == 5);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q2Id) == 7);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q2Id) == 14);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q2Id) == 112);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q2Id) == 275);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q2Id) == 6);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q2Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q3Id) == 15);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q3Id) == 8);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q3Id) == 44);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q3Id) == 144);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q3Id) == 201);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q3Id) == 7);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q3Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q4Id) == 13);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q4Id) == 17);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q4Id) == 78);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q4Id) == 123);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q4Id) == 176);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q4Id) == 12);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q4Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q5Id) == 16);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q5Id) == 18);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q5Id) == 49);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q5Id) == 135);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q5Id) == 188);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q5Id) == 13);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q5Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q6Id) == 21);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q6Id) == 23);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q6Id) == 61);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q6Id) == 131);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q6Id) == 160);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q6Id) == 23);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q6Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q7Id) == 13);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q7Id) == 8);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q7Id) == 57);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q7Id) == 116);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q7Id) == 216);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q7Id) == 9);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q7Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q8Id) == 35);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q8Id) == 27);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q8Id) == 98);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q8Id) == 108);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q8Id) == 124);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q8Id) == 27);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q8Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q9Id) == 19);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q9Id) == 23);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q9Id) == 51);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q9Id) == 107);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q9Id) == 213);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q9Id) == 6);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q9Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q10Id) == 16);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q10Id) == 10);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q10Id) == 66);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q10Id) == 116);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q10Id) == 186);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q10Id) == 25);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q10Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q11Id) == 11);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q11Id) == 8);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q11Id) == 41);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q11Id) == 111);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q11Id) == 211);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q11Id) == 37);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q11Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option0q12Id) == 12);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option25q12Id) == 9);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option50q12Id) == 58);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option75q12Id) == 126);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option100q12Id) == 187);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == option999q12Id) == 27);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q12Id) == 419);

            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == optionq13_1Id) == 289);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q13Id) == 1383);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == optionq13_2Id) == 273);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q13Id) == 1383);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == optionq13_3Id) == 281);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q13Id) == 1383);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == optionq13_4Id) == 271);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q13Id) == 1383);
            Debug.Assert(dbContext.answer_values.Count(x => x.OptionId == optionq13_5Id) == 269);
            Debug.Assert(dbContext.answer_values.Count(x => x.QuestionId == q13Id) == 1383);
            Console.WriteLine("we are done");
        }