Exemplo n.º 1
0
        public void PolSourceSiteEffect_CRUD_Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    PolSourceSiteEffectService polSourceSiteEffectService = new PolSourceSiteEffectService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);

                    int count = 0;
                    if (count == 1)
                    {
                        // just so we don't get a warning during compile [The variable 'count' is assigned but its value is never used]
                    }

                    PolSourceSiteEffect polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");

                    // -------------------------------
                    // -------------------------------
                    // CRUD testing
                    // -------------------------------
                    // -------------------------------

                    count = polSourceSiteEffectService.GetPolSourceSiteEffectList().Count();

                    Assert.AreEqual(count, (from c in dbTestDB.PolSourceSiteEffects select c).Count());

                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    if (polSourceSiteEffect.HasErrors)
                    {
                        Assert.AreEqual("", polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(true, polSourceSiteEffectService.GetPolSourceSiteEffectList().Where(c => c == polSourceSiteEffect).Any());
                    polSourceSiteEffectService.Update(polSourceSiteEffect);
                    if (polSourceSiteEffect.HasErrors)
                    {
                        Assert.AreEqual("", polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(count + 1, polSourceSiteEffectService.GetPolSourceSiteEffectList().Count());
                    polSourceSiteEffectService.Delete(polSourceSiteEffect);
                    if (polSourceSiteEffect.HasErrors)
                    {
                        Assert.AreEqual("", polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(count, polSourceSiteEffectService.GetPolSourceSiteEffectList().Count());
                }
            }
        }
Exemplo n.º 2
0
        public void PolSourceSiteEffect_Properties_Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    PolSourceSiteEffectService polSourceSiteEffectService = new PolSourceSiteEffectService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);

                    int count = 0;
                    if (count == 1)
                    {
                        // just so we don't get a warning during compile [The variable 'count' is assigned but its value is never used]
                    }

                    count = polSourceSiteEffectService.GetPolSourceSiteEffectList().Count();

                    PolSourceSiteEffect polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");

                    // -------------------------------
                    // -------------------------------
                    // Properties testing
                    // -------------------------------
                    // -------------------------------


                    // -----------------------------------
                    // [Key]
                    // Is NOT Nullable
                    // polSourceSiteEffect.PolSourceSiteEffectID   (Int32)
                    // -----------------------------------

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.PolSourceSiteEffectID = 0;
                    polSourceSiteEffectService.Update(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "PolSourceSiteEffectID"), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.PolSourceSiteEffectID = 10000000;
                    polSourceSiteEffectService.Update(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "PolSourceSiteEffect", "PolSourceSiteEffectID", polSourceSiteEffect.PolSourceSiteEffectID.ToString()), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);


                    // -----------------------------------
                    // Is NOT Nullable
                    // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Infrastructure,PolSourceSite)]
                    // polSourceSiteEffect.PolSourceSiteOrInfrastructureTVItemID   (Int32)
                    // -----------------------------------

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.PolSourceSiteOrInfrastructureTVItemID = 0;
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "PolSourceSiteOrInfrastructureTVItemID", polSourceSiteEffect.PolSourceSiteOrInfrastructureTVItemID.ToString()), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.PolSourceSiteOrInfrastructureTVItemID = 1;
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "PolSourceSiteOrInfrastructureTVItemID", "Infrastructure,PolSourceSite"), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);


                    // -----------------------------------
                    // Is NOT Nullable
                    // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = MWQMSite)]
                    // polSourceSiteEffect.MWQMSiteTVItemID   (Int32)
                    // -----------------------------------

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.MWQMSiteTVItemID = 0;
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "MWQMSiteTVItemID", polSourceSiteEffect.MWQMSiteTVItemID.ToString()), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.MWQMSiteTVItemID = 1;
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "MWQMSiteTVItemID", "MWQMSite"), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);


                    // -----------------------------------
                    // Is Nullable
                    // [StringLength(250))]
                    // polSourceSiteEffect.PolSourceSiteEffectTermIDs   (String)
                    // -----------------------------------

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.PolSourceSiteEffectTermIDs = GetRandomString("", 251);
                    Assert.AreEqual(false, polSourceSiteEffectService.Add(polSourceSiteEffect));
                    Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "PolSourceSiteEffectTermIDs", "250"), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);
                    Assert.AreEqual(count, polSourceSiteEffectService.GetPolSourceSiteEffectList().Count());

                    // -----------------------------------
                    // Is Nullable
                    // polSourceSiteEffect.Comments   (String)
                    // -----------------------------------


                    // -----------------------------------
                    // Is Nullable
                    // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = File)]
                    // polSourceSiteEffect.AnalysisDocumentTVItemID   (Int32)
                    // -----------------------------------

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.AnalysisDocumentTVItemID = 0;
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "AnalysisDocumentTVItemID", polSourceSiteEffect.AnalysisDocumentTVItemID.ToString()), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.AnalysisDocumentTVItemID = 1;
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "AnalysisDocumentTVItemID", "File"), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);


                    // -----------------------------------
                    // Is NOT Nullable
                    // [CSSPAfter(Year = 1980)]
                    // polSourceSiteEffect.LastUpdateDate_UTC   (DateTime)
                    // -----------------------------------

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.LastUpdateDate_UTC = new DateTime();
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);
                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.LastUpdateDate_UTC = new DateTime(1979, 1, 1);
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);

                    // -----------------------------------
                    // Is NOT Nullable
                    // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)]
                    // polSourceSiteEffect.LastUpdateContactTVItemID   (Int32)
                    // -----------------------------------

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.LastUpdateContactTVItemID = 0;
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", polSourceSiteEffect.LastUpdateContactTVItemID.ToString()), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);

                    polSourceSiteEffect = null;
                    polSourceSiteEffect = GetFilledRandomPolSourceSiteEffect("");
                    polSourceSiteEffect.LastUpdateContactTVItemID = 1;
                    polSourceSiteEffectService.Add(polSourceSiteEffect);
                    Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), polSourceSiteEffect.ValidationResults.FirstOrDefault().ErrorMessage);


                    // -----------------------------------
                    // Is NOT Nullable
                    // [NotMapped]
                    // polSourceSiteEffect.HasErrors   (Boolean)
                    // -----------------------------------

                    // No testing requied

                    // -----------------------------------
                    // Is NOT Nullable
                    // [NotMapped]
                    // polSourceSiteEffect.ValidationResults   (IEnumerable`1)
                    // -----------------------------------

                    // No testing requied
                }
            }
        }