public void GetInsuranceCompanyIdTest()
        {
            MemoryMappings.AddCompnay("12345", "Acme Insurance");

            Mock <DbSet <SQLDatabase.EF.InsuranceProvider> > moq_Ins = new Mock <DbSet <InsuranceProvider> >();

            moq_Ins.SetupData(new List <SQLDatabase.EF.InsuranceProvider>());

            var nIns = new InsuranceProvider
            {
                Name      = "Acme Insurance",
                IsActive  = true,
                CompanyId = 12345
            };

            moq_Ins.Object.Add(nIns);

            nuContext.Setup(c => c.InsuranceProviders).Returns(moq_Ins.Object);
            NumedicsGlobalHelpers nh = new NumedicsGlobalHelpers(nuContext.Object);

            // verify insurance id is returned
            Assert.AreEqual(nIns.CompanyId, nh.GetInsuranceCompanyId(nIns.CompanyId.ToString()));
            // verify 0 is returned for insurance providers not found
            Assert.IsTrue(nh.GetInsuranceCompanyId("99999").Equals(0));
        }
예제 #2
0
        public void CreateInsuranceCompanyMapping()
        {
            try
            {
                var dataSet = TableAgent.DataSet.Tables[FbTableName].Rows;
                RecordCount = TableAgent.RowCount;

                foreach (DataRow row in dataSet)
                {
                    if (!String.IsNullOrEmpty(row["NAME"].ToString()))
                    {
                        var name = row["NAME"].ToString();
                        var kId  = row["KEYID"].ToString();

                        MemoryMappings.AddCompnay(kId, name);

                        var ips = new InsuranceProvider
                        {
                            Name              = name,
                            IsActive          = map.ParseFirebirdBoolean(row["ISACTIVE"].ToString()),
                            InActiveDate      = map.ParseFirebirdDateTime(row["INACTIVEDATE"].ToString()),
                            LastUpdatedByUser = Guid.Empty
                        };

                        var adr = new InsuranceAddress
                        {
                            Street1           = (row["STREET1"] is DBNull) ? String.Empty : row["STREET1"].ToString(),
                            Street2           = (row["STREET2"] is DBNull) ? String.Empty : row["STREET2"].ToString(),
                            Street3           = (row["STREET3"] is DBNull) ? String.Empty : row["STREET3"].ToString(),
                            City              = (row["CITY"] is DBNull) ? String.Empty : row["CITY"].ToString(),
                            State             = (row["STATE"] is DBNull) ? String.Empty : row["STATE"].ToString(),
                            Zip               = (row["ZIP"] is DBNull) ? String.Empty : row["ZIP"].ToString(),
                            Country           = (row["COUNTRY"] is DBNull) ? String.Empty : row["COUNTRY"].ToString(),
                            LastUpdatedByUser = Guid.Empty
                        };

                        var cont = new InsuranceContact
                        {
                            FullName          = (row["CONTACTNAME"] is DBNull) ? "No Name" : row["CONTACTNAME"].ToString(),
                            Email             = (row["EMAIL"] is DBNull) ? String.Empty : row["EMAIL"].ToString(),
                            LastUpdatedByUser = Guid.Empty
                        };

                        ips.InsuranceAddresses.Add(adr);
                        ips.InsuranceContacts.Add(cont);

                        if (CanAddToContext(ips.Name))
                        {
                            CompletedMappings.Add(ips);
                        }
                        else
                        {
                            MappingStatistics.LogFailedMapping("INSURANCECOS", kId, "InsuranceProviders", typeof(InsuranceProvider), JsonConvert.SerializeObject(ips), "Insurance Provider already exist in database.");
                            FailedCount++;
                        }
                    }
                }

                MappingStatistics.LogMappingStat("INSURANCECOS", RecordCount, "InsuranceProviders", CompletedMappings.Count, FailedCount);
            }
            catch (Exception e)
            {
                throw new Exception("Error creating InsuranceProvider mapping.", e);
            }
        }