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

                    RatingCurve ratingCurveLast = new RatingCurve();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        RatingCurveService ratingCurveService = new RatingCurveService(query, db, ContactID);
                        ratingCurveLast = (from c in db.RatingCurves select c).FirstOrDefault();
                    }

                    // ok with RatingCurve info
                    IHttpActionResult jsonRet = ratingCurveController.GetRatingCurveWithID(ratingCurveLast.RatingCurveID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <RatingCurve> Ret = jsonRet as OkNegotiatedContentResult <RatingCurve>;
                    RatingCurve ratingCurveRet = Ret.Content;
                    Assert.AreEqual(ratingCurveLast.RatingCurveID, ratingCurveRet.RatingCurveID);

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

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

                    OkNegotiatedContentResult <RatingCurve> ratingCurveRet2 = jsonRet2 as OkNegotiatedContentResult <RatingCurve>;
                    Assert.IsNotNull(ratingCurveRet2);

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

                    // Put to return CSSPError because RatingCurveID of 0 does not exist
                    ratingCurveRet.RatingCurveID = 0;
                    IHttpActionResult jsonRet3 = ratingCurveController.Put(ratingCurveRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <RatingCurve> ratingCurveRet3 = jsonRet3 as OkNegotiatedContentResult <RatingCurve>;
                    Assert.IsNull(ratingCurveRet3);

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

                    RatingCurve ratingCurveFirst = new RatingCurve();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        RatingCurveService ratingCurveService = new RatingCurveService(new Query(), db, ContactID);
                        ratingCurveFirst = (from c in db.RatingCurves select c).FirstOrDefault();
                    }

                    // ok with RatingCurve info
                    IHttpActionResult jsonRet = ratingCurveController.GetRatingCurveWithID(ratingCurveFirst.RatingCurveID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <RatingCurve> Ret = jsonRet as OkNegotiatedContentResult <RatingCurve>;
                    RatingCurve ratingCurveRet = Ret.Content;
                    Assert.AreEqual(ratingCurveFirst.RatingCurveID, ratingCurveRet.RatingCurveID);

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

                    // Not Found
                    IHttpActionResult jsonRet2 = ratingCurveController.GetRatingCurveWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <RatingCurve> ratingCurveRet2 = jsonRet2 as OkNegotiatedContentResult <RatingCurve>;
                    Assert.IsNull(ratingCurveRet2);

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

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

                        RatingCurveService ratingCurveService = new RatingCurveService(query, db, ContactID);
                        ratingCurveLast = (from c in db.RatingCurves select c).FirstOrDefault();
                    }

                    // ok with RatingCurve info
                    IHttpActionResult jsonRet = ratingCurveController.GetRatingCurveWithID(ratingCurveLast.RatingCurveID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <RatingCurve> Ret = jsonRet as OkNegotiatedContentResult <RatingCurve>;
                    RatingCurve ratingCurveRet = Ret.Content;
                    Assert.AreEqual(ratingCurveLast.RatingCurveID, ratingCurveRet.RatingCurveID);

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

                    // Post to return CSSPError because RatingCurveID exist
                    IHttpActionResult jsonRet2 = ratingCurveController.Post(ratingCurveRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <RatingCurve> ratingCurveRet2 = jsonRet2 as OkNegotiatedContentResult <RatingCurve>;
                    Assert.IsNull(ratingCurveRet2);

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

                    // Post to return newly added RatingCurve
                    ratingCurveRet.RatingCurveID             = 0;
                    ratingCurveController.Request            = new System.Net.Http.HttpRequestMessage();
                    ratingCurveController.Request.RequestUri = new System.Uri("http://localhost:5000/api/ratingCurve");
                    IHttpActionResult jsonRet3 = ratingCurveController.Post(ratingCurveRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <RatingCurve> ratingCurveRet3 = jsonRet3 as CreatedNegotiatedContentResult <RatingCurve>;
                    Assert.IsNotNull(ratingCurveRet3);

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

                    IHttpActionResult jsonRet4 = ratingCurveController.Delete(ratingCurveRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <RatingCurve> ratingCurveRet4 = jsonRet4 as OkNegotiatedContentResult <RatingCurve>;
                    Assert.IsNotNull(ratingCurveRet4);

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