public void PolSourceSiteEffectTerm_Controller_Put_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    PolSourceSiteEffectTermController polSourceSiteEffectTermController = new PolSourceSiteEffectTermController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(polSourceSiteEffectTermController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, polSourceSiteEffectTermController.DatabaseType);

                    PolSourceSiteEffectTerm polSourceSiteEffectTermLast = new PolSourceSiteEffectTerm();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        PolSourceSiteEffectTermService polSourceSiteEffectTermService = new PolSourceSiteEffectTermService(query, db, ContactID);
                        polSourceSiteEffectTermLast = (from c in db.PolSourceSiteEffectTerms select c).FirstOrDefault();
                    }

                    // ok with PolSourceSiteEffectTerm info
                    IHttpActionResult jsonRet = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermWithID(polSourceSiteEffectTermLast.PolSourceSiteEffectTermID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <PolSourceSiteEffectTerm> Ret = jsonRet as OkNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    PolSourceSiteEffectTerm polSourceSiteEffectTermRet      = Ret.Content;
                    Assert.AreEqual(polSourceSiteEffectTermLast.PolSourceSiteEffectTermID, polSourceSiteEffectTermRet.PolSourceSiteEffectTermID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Put to return success
                    IHttpActionResult jsonRet2 = polSourceSiteEffectTermController.Put(polSourceSiteEffectTermRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet2 = jsonRet2 as OkNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    Assert.IsNotNull(polSourceSiteEffectTermRet2);

                    BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest2);

                    // Put to return CSSPError because PolSourceSiteEffectTermID of 0 does not exist
                    polSourceSiteEffectTermRet.PolSourceSiteEffectTermID = 0;
                    IHttpActionResult jsonRet3 = polSourceSiteEffectTermController.Put(polSourceSiteEffectTermRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet3 = jsonRet3 as OkNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    Assert.IsNull(polSourceSiteEffectTermRet3);

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest3);
                }
            }
        }
        public void PolSourceSiteEffectTerm_Controller_GetPolSourceSiteEffectTermWithID_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    PolSourceSiteEffectTermController polSourceSiteEffectTermController = new PolSourceSiteEffectTermController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(polSourceSiteEffectTermController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, polSourceSiteEffectTermController.DatabaseType);

                    PolSourceSiteEffectTerm polSourceSiteEffectTermFirst = new PolSourceSiteEffectTerm();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        PolSourceSiteEffectTermService polSourceSiteEffectTermService = new PolSourceSiteEffectTermService(new Query(), db, ContactID);
                        polSourceSiteEffectTermFirst = (from c in db.PolSourceSiteEffectTerms select c).FirstOrDefault();
                    }

                    // ok with PolSourceSiteEffectTerm info
                    IHttpActionResult jsonRet = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermWithID(polSourceSiteEffectTermFirst.PolSourceSiteEffectTermID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <PolSourceSiteEffectTerm> Ret = jsonRet as OkNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    PolSourceSiteEffectTerm polSourceSiteEffectTermRet      = Ret.Content;
                    Assert.AreEqual(polSourceSiteEffectTermFirst.PolSourceSiteEffectTermID, polSourceSiteEffectTermRet.PolSourceSiteEffectTermID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Not Found
                    IHttpActionResult jsonRet2 = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet2 = jsonRet2 as OkNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    Assert.IsNull(polSourceSiteEffectTermRet2);

                    NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult;
                    Assert.IsNotNull(notFoundRequest);
                }
            }
        }
        public void PolSourceSiteEffectTerm_Controller_GetPolSourceSiteEffectTermList_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    PolSourceSiteEffectTermController polSourceSiteEffectTermController = new PolSourceSiteEffectTermController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(polSourceSiteEffectTermController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, polSourceSiteEffectTermController.DatabaseType);

                    PolSourceSiteEffectTerm polSourceSiteEffectTermFirst = new PolSourceSiteEffectTerm();
                    int   count = -1;
                    Query query = new Query();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                    {
                        PolSourceSiteEffectTermService polSourceSiteEffectTermService = new PolSourceSiteEffectTermService(query, db, ContactID);
                        polSourceSiteEffectTermFirst = (from c in db.PolSourceSiteEffectTerms select c).FirstOrDefault();
                        count = (from c in db.PolSourceSiteEffectTerms select c).Count();
                        count = (query.Take > count ? count : query.Take);
                    }

                    // ok with PolSourceSiteEffectTerm info
                    IHttpActionResult jsonRet = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermList();
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> > ret = jsonRet as OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> >;
                    Assert.AreEqual(polSourceSiteEffectTermFirst.PolSourceSiteEffectTermID, ret.Content[0].PolSourceSiteEffectTermID);
                    Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count);

                    List <PolSourceSiteEffectTerm> polSourceSiteEffectTermList = new List <PolSourceSiteEffectTerm>();
                    count = -1;
                    query = new Query();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                    {
                        PolSourceSiteEffectTermService polSourceSiteEffectTermService = new PolSourceSiteEffectTermService(query, db, ContactID);
                        polSourceSiteEffectTermList = (from c in db.PolSourceSiteEffectTerms select c).OrderBy(c => c.PolSourceSiteEffectTermID).Skip(0).Take(2).ToList();
                        count = (from c in db.PolSourceSiteEffectTerms select c).Count();
                    }

                    if (count > 0)
                    {
                        query.Skip = 0;
                        query.Take = 5;
                        count      = (query.Take > count ? query.Take : count);

                        // ok with PolSourceSiteEffectTerm info
                        jsonRet = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermList(query.Language.ToString(), query.Skip, query.Take);
                        Assert.IsNotNull(jsonRet);

                        ret = jsonRet as OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> >;
                        Assert.AreEqual(polSourceSiteEffectTermList[0].PolSourceSiteEffectTermID, ret.Content[0].PolSourceSiteEffectTermID);
                        Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count);

                        if (count > 1)
                        {
                            query.Skip = 1;
                            query.Take = 5;
                            count      = (query.Take > count ? query.Take : count);

                            // ok with PolSourceSiteEffectTerm info
                            IHttpActionResult jsonRet2 = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermList(query.Language.ToString(), query.Skip, query.Take);
                            Assert.IsNotNull(jsonRet2);

                            OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> > ret2 = jsonRet2 as OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> >;
                            Assert.AreEqual(polSourceSiteEffectTermList[1].PolSourceSiteEffectTermID, ret2.Content[0].PolSourceSiteEffectTermID);
                            Assert.AreEqual((count > query.Take ? query.Take : count), ret2.Content.Count);
                        }
                    }
                }
            }
        }
        public void PolSourceSiteEffectTerm_Controller_Post_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    PolSourceSiteEffectTermController polSourceSiteEffectTermController = new PolSourceSiteEffectTermController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(polSourceSiteEffectTermController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, polSourceSiteEffectTermController.DatabaseType);

                    PolSourceSiteEffectTerm polSourceSiteEffectTermLast = new PolSourceSiteEffectTerm();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;
                        query.Asc      = "";
                        query.Desc     = "";

                        PolSourceSiteEffectTermService polSourceSiteEffectTermService = new PolSourceSiteEffectTermService(query, db, ContactID);
                        polSourceSiteEffectTermLast = (from c in db.PolSourceSiteEffectTerms select c).FirstOrDefault();
                    }

                    // ok with PolSourceSiteEffectTerm info
                    IHttpActionResult jsonRet = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermWithID(polSourceSiteEffectTermLast.PolSourceSiteEffectTermID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <PolSourceSiteEffectTerm> Ret = jsonRet as OkNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    PolSourceSiteEffectTerm polSourceSiteEffectTermRet      = Ret.Content;
                    Assert.AreEqual(polSourceSiteEffectTermLast.PolSourceSiteEffectTermID, polSourceSiteEffectTermRet.PolSourceSiteEffectTermID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Post to return CSSPError because PolSourceSiteEffectTermID exist
                    IHttpActionResult jsonRet2 = polSourceSiteEffectTermController.Post(polSourceSiteEffectTermRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet2 = jsonRet2 as OkNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    Assert.IsNull(polSourceSiteEffectTermRet2);

                    BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest2);

                    // Post to return newly added PolSourceSiteEffectTerm
                    polSourceSiteEffectTermRet.PolSourceSiteEffectTermID = 0;
                    polSourceSiteEffectTermController.Request            = new System.Net.Http.HttpRequestMessage();
                    polSourceSiteEffectTermController.Request.RequestUri = new System.Uri("http://localhost:5000/api/polSourceSiteEffectTerm");
                    IHttpActionResult jsonRet3 = polSourceSiteEffectTermController.Post(polSourceSiteEffectTermRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet3 = jsonRet3 as CreatedNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    Assert.IsNotNull(polSourceSiteEffectTermRet3);

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest3);

                    IHttpActionResult jsonRet4 = polSourceSiteEffectTermController.Delete(polSourceSiteEffectTermRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet4 = jsonRet4 as OkNegotiatedContentResult <PolSourceSiteEffectTerm>;
                    Assert.IsNotNull(polSourceSiteEffectTermRet4);

                    BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest4);
                }
            }
        }