Example #1
0
        public void SamplingPlanSubsectorSite_Controller_Put_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    SamplingPlanSubsectorSiteController samplingPlanSubsectorSiteController = new SamplingPlanSubsectorSiteController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(samplingPlanSubsectorSiteController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, samplingPlanSubsectorSiteController.DatabaseType);

                    SamplingPlanSubsectorSite samplingPlanSubsectorSiteLast = new SamplingPlanSubsectorSite();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        SamplingPlanSubsectorSiteService samplingPlanSubsectorSiteService = new SamplingPlanSubsectorSiteService(query, db, ContactID);
                        samplingPlanSubsectorSiteLast = (from c in db.SamplingPlanSubsectorSites select c).FirstOrDefault();
                    }

                    // ok with SamplingPlanSubsectorSite info
                    IHttpActionResult jsonRet = samplingPlanSubsectorSiteController.GetSamplingPlanSubsectorSiteWithID(samplingPlanSubsectorSiteLast.SamplingPlanSubsectorSiteID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <SamplingPlanSubsectorSite> Ret = jsonRet as OkNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    SamplingPlanSubsectorSite samplingPlanSubsectorSiteRet    = Ret.Content;
                    Assert.AreEqual(samplingPlanSubsectorSiteLast.SamplingPlanSubsectorSiteID, samplingPlanSubsectorSiteRet.SamplingPlanSubsectorSiteID);

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

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

                    OkNegotiatedContentResult <SamplingPlanSubsectorSite> samplingPlanSubsectorSiteRet2 = jsonRet2 as OkNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    Assert.IsNotNull(samplingPlanSubsectorSiteRet2);

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

                    // Put to return CSSPError because SamplingPlanSubsectorSiteID of 0 does not exist
                    samplingPlanSubsectorSiteRet.SamplingPlanSubsectorSiteID = 0;
                    IHttpActionResult jsonRet3 = samplingPlanSubsectorSiteController.Put(samplingPlanSubsectorSiteRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <SamplingPlanSubsectorSite> samplingPlanSubsectorSiteRet3 = jsonRet3 as OkNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    Assert.IsNull(samplingPlanSubsectorSiteRet3);

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest3);
                }
            }
        }
Example #2
0
        public void SamplingPlanSubsectorSite_Controller_GetSamplingPlanSubsectorSiteWithID_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    SamplingPlanSubsectorSiteController samplingPlanSubsectorSiteController = new SamplingPlanSubsectorSiteController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(samplingPlanSubsectorSiteController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, samplingPlanSubsectorSiteController.DatabaseType);

                    SamplingPlanSubsectorSite samplingPlanSubsectorSiteFirst = new SamplingPlanSubsectorSite();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        SamplingPlanSubsectorSiteService samplingPlanSubsectorSiteService = new SamplingPlanSubsectorSiteService(new Query(), db, ContactID);
                        samplingPlanSubsectorSiteFirst = (from c in db.SamplingPlanSubsectorSites select c).FirstOrDefault();
                    }

                    // ok with SamplingPlanSubsectorSite info
                    IHttpActionResult jsonRet = samplingPlanSubsectorSiteController.GetSamplingPlanSubsectorSiteWithID(samplingPlanSubsectorSiteFirst.SamplingPlanSubsectorSiteID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <SamplingPlanSubsectorSite> Ret = jsonRet as OkNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    SamplingPlanSubsectorSite samplingPlanSubsectorSiteRet    = Ret.Content;
                    Assert.AreEqual(samplingPlanSubsectorSiteFirst.SamplingPlanSubsectorSiteID, samplingPlanSubsectorSiteRet.SamplingPlanSubsectorSiteID);

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

                    // Not Found
                    IHttpActionResult jsonRet2 = samplingPlanSubsectorSiteController.GetSamplingPlanSubsectorSiteWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <SamplingPlanSubsectorSite> samplingPlanSubsectorSiteRet2 = jsonRet2 as OkNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    Assert.IsNull(samplingPlanSubsectorSiteRet2);

                    NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult;
                    Assert.IsNotNull(notFoundRequest);
                }
            }
        }
Example #3
0
        public void SamplingPlanSubsectorSite_Controller_Post_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    SamplingPlanSubsectorSiteController samplingPlanSubsectorSiteController = new SamplingPlanSubsectorSiteController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(samplingPlanSubsectorSiteController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, samplingPlanSubsectorSiteController.DatabaseType);

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

                        SamplingPlanSubsectorSiteService samplingPlanSubsectorSiteService = new SamplingPlanSubsectorSiteService(query, db, ContactID);
                        samplingPlanSubsectorSiteLast = (from c in db.SamplingPlanSubsectorSites select c).FirstOrDefault();
                    }

                    // ok with SamplingPlanSubsectorSite info
                    IHttpActionResult jsonRet = samplingPlanSubsectorSiteController.GetSamplingPlanSubsectorSiteWithID(samplingPlanSubsectorSiteLast.SamplingPlanSubsectorSiteID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <SamplingPlanSubsectorSite> Ret = jsonRet as OkNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    SamplingPlanSubsectorSite samplingPlanSubsectorSiteRet    = Ret.Content;
                    Assert.AreEqual(samplingPlanSubsectorSiteLast.SamplingPlanSubsectorSiteID, samplingPlanSubsectorSiteRet.SamplingPlanSubsectorSiteID);

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

                    // Post to return CSSPError because SamplingPlanSubsectorSiteID exist
                    IHttpActionResult jsonRet2 = samplingPlanSubsectorSiteController.Post(samplingPlanSubsectorSiteRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <SamplingPlanSubsectorSite> samplingPlanSubsectorSiteRet2 = jsonRet2 as OkNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    Assert.IsNull(samplingPlanSubsectorSiteRet2);

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

                    // Post to return newly added SamplingPlanSubsectorSite
                    samplingPlanSubsectorSiteRet.SamplingPlanSubsectorSiteID = 0;
                    samplingPlanSubsectorSiteController.Request            = new System.Net.Http.HttpRequestMessage();
                    samplingPlanSubsectorSiteController.Request.RequestUri = new System.Uri("http://localhost:5000/api/samplingPlanSubsectorSite");
                    IHttpActionResult jsonRet3 = samplingPlanSubsectorSiteController.Post(samplingPlanSubsectorSiteRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <SamplingPlanSubsectorSite> samplingPlanSubsectorSiteRet3 = jsonRet3 as CreatedNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    Assert.IsNotNull(samplingPlanSubsectorSiteRet3);

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

                    IHttpActionResult jsonRet4 = samplingPlanSubsectorSiteController.Delete(samplingPlanSubsectorSiteRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <SamplingPlanSubsectorSite> samplingPlanSubsectorSiteRet4 = jsonRet4 as OkNegotiatedContentResult <SamplingPlanSubsectorSite>;
                    Assert.IsNotNull(samplingPlanSubsectorSiteRet4);

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