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

                    TideSite tideSiteLast = new TideSite();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        TideSiteService tideSiteService = new TideSiteService(query, db, ContactID);
                        tideSiteLast = (from c in db.TideSites select c).FirstOrDefault();
                    }

                    // ok with TideSite info
                    IHttpActionResult jsonRet = tideSiteController.GetTideSiteWithID(tideSiteLast.TideSiteID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <TideSite> Ret = jsonRet as OkNegotiatedContentResult <TideSite>;
                    TideSite tideSiteRet = Ret.Content;
                    Assert.AreEqual(tideSiteLast.TideSiteID, tideSiteRet.TideSiteID);

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

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

                    OkNegotiatedContentResult <TideSite> tideSiteRet2 = jsonRet2 as OkNegotiatedContentResult <TideSite>;
                    Assert.IsNotNull(tideSiteRet2);

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

                    // Put to return CSSPError because TideSiteID of 0 does not exist
                    tideSiteRet.TideSiteID = 0;
                    IHttpActionResult jsonRet3 = tideSiteController.Put(tideSiteRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <TideSite> tideSiteRet3 = jsonRet3 as OkNegotiatedContentResult <TideSite>;
                    Assert.IsNull(tideSiteRet3);

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

                    TideSite tideSiteFirst = new TideSite();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        TideSiteService tideSiteService = new TideSiteService(new Query(), db, ContactID);
                        tideSiteFirst = (from c in db.TideSites select c).FirstOrDefault();
                    }

                    // ok with TideSite info
                    IHttpActionResult jsonRet = tideSiteController.GetTideSiteWithID(tideSiteFirst.TideSiteID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <TideSite> Ret = jsonRet as OkNegotiatedContentResult <TideSite>;
                    TideSite tideSiteRet = Ret.Content;
                    Assert.AreEqual(tideSiteFirst.TideSiteID, tideSiteRet.TideSiteID);

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

                    // Not Found
                    IHttpActionResult jsonRet2 = tideSiteController.GetTideSiteWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <TideSite> tideSiteRet2 = jsonRet2 as OkNegotiatedContentResult <TideSite>;
                    Assert.IsNull(tideSiteRet2);

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

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

                        TideSiteService tideSiteService = new TideSiteService(query, db, ContactID);
                        tideSiteLast = (from c in db.TideSites select c).FirstOrDefault();
                    }

                    // ok with TideSite info
                    IHttpActionResult jsonRet = tideSiteController.GetTideSiteWithID(tideSiteLast.TideSiteID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <TideSite> Ret = jsonRet as OkNegotiatedContentResult <TideSite>;
                    TideSite tideSiteRet = Ret.Content;
                    Assert.AreEqual(tideSiteLast.TideSiteID, tideSiteRet.TideSiteID);

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

                    // Post to return CSSPError because TideSiteID exist
                    IHttpActionResult jsonRet2 = tideSiteController.Post(tideSiteRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <TideSite> tideSiteRet2 = jsonRet2 as OkNegotiatedContentResult <TideSite>;
                    Assert.IsNull(tideSiteRet2);

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

                    // Post to return newly added TideSite
                    tideSiteRet.TideSiteID                = 0;
                    tideSiteController.Request            = new System.Net.Http.HttpRequestMessage();
                    tideSiteController.Request.RequestUri = new System.Uri("http://localhost:5000/api/tideSite");
                    IHttpActionResult jsonRet3 = tideSiteController.Post(tideSiteRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <TideSite> tideSiteRet3 = jsonRet3 as CreatedNegotiatedContentResult <TideSite>;
                    Assert.IsNotNull(tideSiteRet3);

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

                    IHttpActionResult jsonRet4 = tideSiteController.Delete(tideSiteRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <TideSite> tideSiteRet4 = jsonRet4 as OkNegotiatedContentResult <TideSite>;
                    Assert.IsNotNull(tideSiteRet4);

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