Пример #1
0
        public void GetAllAdminsTest()
        {
            Mock <DbSet <SQLDatabase.EF.clinipro_Users> > moq_cpusers = new Mock <DbSet <SQLDatabase.EF.clinipro_Users> >();

            moq_cpusers.SetupData(cpUsers);

            nuContext.Setup(c => c.clinipro_Users).Returns(moq_cpusers.Object);
            AspnetDbHelpers ah = new AspnetDbHelpers(nuContext.Object);

            int exp = db.clinipro_Users.Where(w => w.CliniProID.ToLower() == "admin").Count();
            int act = ah.GetAllAdminsUsers().Count;

            Assert.AreEqual(exp, act);
        }
        public void CreateClinicianMapping()
        {
            try
            {
                var dataSet = aHelper.GetAllAdminsUsers().Where(w => w.CPSiteId == MigrationVariables.CurrentSiteId).ToList();
                RecordCount = dataSet.Count;

                foreach (var adUser in dataSet)
                {
                    var userInfo = aHelper.GetAspUserInfo(adUser.UserId);
                    if (mHelper.HasUserMigrated((userInfo == null) ? String.Empty : userInfo.UserName, adUser.UserId))
                    {
                        MappingStatistics.LogFailedMapping("None", "None", "Clinicians", typeof(Clinician), String.Empty, "Clinician previously migrated.");
                        FailedCount++;
                    }
                    else
                    {
                        var clin = new Clinician
                        {
                            UserId             = nHelper.ValidGuid(adUser.UserId),
                            Firstname          = "No Name",
                            Lastname           = "No Name",
                            StateLicenseNumber = "No License Number",
                            Email                = "",
                            InstitutionId        = nHelper.GetInstitutionId(MigrationVariables.CurrentSiteId),
                            InstitutionAddressId = 0//nHelper.GetInstitutionAddressId(MigrationVariables.CurrentSiteId),
                        };

                        clin.LastUpdatedByUser = clin.UserId;

                        if (CanAddToContext(clin.UserId))
                        {
                            CompletedMappings.Add(clin);
                        }
                        else
                        {
                            MappingStatistics.LogFailedMapping("None", "None", "Clinicians", typeof(Clinician), JsonConvert.SerializeObject(clin), "Clinician already exist in database.");
                            FailedCount++;
                        }
                    }
                }

                MappingStatistics.LogMappingStat("None", 0, "Clinicians", CompletedMappings.Count, FailedCount);
            }
            catch (Exception e)
            {
                throw new Exception("Error creating Clinician mapping.", e);
            }
        }