Exemplo n.º 1
0
        public void AppTaskLanguage_Controller_Put_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    AppTaskLanguageController appTaskLanguageController = new AppTaskLanguageController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(appTaskLanguageController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, appTaskLanguageController.DatabaseType);

                    AppTaskLanguage appTaskLanguageLast = new AppTaskLanguage();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        AppTaskLanguageService appTaskLanguageService = new AppTaskLanguageService(query, db, ContactID);
                        appTaskLanguageLast = (from c in db.AppTaskLanguages select c).FirstOrDefault();
                    }

                    // ok with AppTaskLanguage info
                    IHttpActionResult jsonRet = appTaskLanguageController.GetAppTaskLanguageWithID(appTaskLanguageLast.AppTaskLanguageID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <AppTaskLanguage> Ret = jsonRet as OkNegotiatedContentResult <AppTaskLanguage>;
                    AppTaskLanguage appTaskLanguageRet = Ret.Content;
                    Assert.AreEqual(appTaskLanguageLast.AppTaskLanguageID, appTaskLanguageRet.AppTaskLanguageID);

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

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

                    OkNegotiatedContentResult <AppTaskLanguage> appTaskLanguageRet2 = jsonRet2 as OkNegotiatedContentResult <AppTaskLanguage>;
                    Assert.IsNotNull(appTaskLanguageRet2);

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

                    // Put to return CSSPError because AppTaskLanguageID of 0 does not exist
                    appTaskLanguageRet.AppTaskLanguageID = 0;
                    IHttpActionResult jsonRet3 = appTaskLanguageController.Put(appTaskLanguageRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <AppTaskLanguage> appTaskLanguageRet3 = jsonRet3 as OkNegotiatedContentResult <AppTaskLanguage>;
                    Assert.IsNull(appTaskLanguageRet3);

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest3);
                }
            }
        }
Exemplo n.º 2
0
        public void AppTaskLanguage_Controller_GetAppTaskLanguageWithID_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    AppTaskLanguageController appTaskLanguageController = new AppTaskLanguageController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(appTaskLanguageController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, appTaskLanguageController.DatabaseType);

                    AppTaskLanguage appTaskLanguageFirst = new AppTaskLanguage();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        AppTaskLanguageService appTaskLanguageService = new AppTaskLanguageService(new Query(), db, ContactID);
                        appTaskLanguageFirst = (from c in db.AppTaskLanguages select c).FirstOrDefault();
                    }

                    // ok with AppTaskLanguage info
                    IHttpActionResult jsonRet = appTaskLanguageController.GetAppTaskLanguageWithID(appTaskLanguageFirst.AppTaskLanguageID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <AppTaskLanguage> Ret = jsonRet as OkNegotiatedContentResult <AppTaskLanguage>;
                    AppTaskLanguage appTaskLanguageRet = Ret.Content;
                    Assert.AreEqual(appTaskLanguageFirst.AppTaskLanguageID, appTaskLanguageRet.AppTaskLanguageID);

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

                    // Not Found
                    IHttpActionResult jsonRet2 = appTaskLanguageController.GetAppTaskLanguageWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <AppTaskLanguage> appTaskLanguageRet2 = jsonRet2 as OkNegotiatedContentResult <AppTaskLanguage>;
                    Assert.IsNull(appTaskLanguageRet2);

                    NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult;
                    Assert.IsNotNull(notFoundRequest);
                }
            }
        }
Exemplo n.º 3
0
        public void AppTaskLanguage_Controller_Post_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    AppTaskLanguageController appTaskLanguageController = new AppTaskLanguageController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(appTaskLanguageController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, appTaskLanguageController.DatabaseType);

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

                        AppTaskLanguageService appTaskLanguageService = new AppTaskLanguageService(query, db, ContactID);
                        appTaskLanguageLast = (from c in db.AppTaskLanguages select c).FirstOrDefault();
                    }

                    // ok with AppTaskLanguage info
                    IHttpActionResult jsonRet = appTaskLanguageController.GetAppTaskLanguageWithID(appTaskLanguageLast.AppTaskLanguageID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <AppTaskLanguage> Ret = jsonRet as OkNegotiatedContentResult <AppTaskLanguage>;
                    AppTaskLanguage appTaskLanguageRet = Ret.Content;
                    Assert.AreEqual(appTaskLanguageLast.AppTaskLanguageID, appTaskLanguageRet.AppTaskLanguageID);

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

                    // Post to return CSSPError because AppTaskLanguageID exist
                    IHttpActionResult jsonRet2 = appTaskLanguageController.Post(appTaskLanguageRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <AppTaskLanguage> appTaskLanguageRet2 = jsonRet2 as OkNegotiatedContentResult <AppTaskLanguage>;
                    Assert.IsNull(appTaskLanguageRet2);

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

                    // Post to return newly added AppTaskLanguage
                    appTaskLanguageRet.AppTaskLanguageID         = 0;
                    appTaskLanguageController.Request            = new System.Net.Http.HttpRequestMessage();
                    appTaskLanguageController.Request.RequestUri = new System.Uri("http://localhost:5000/api/appTaskLanguage");
                    IHttpActionResult jsonRet3 = appTaskLanguageController.Post(appTaskLanguageRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <AppTaskLanguage> appTaskLanguageRet3 = jsonRet3 as CreatedNegotiatedContentResult <AppTaskLanguage>;
                    Assert.IsNotNull(appTaskLanguageRet3);

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

                    IHttpActionResult jsonRet4 = appTaskLanguageController.Delete(appTaskLanguageRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <AppTaskLanguage> appTaskLanguageRet4 = jsonRet4 as OkNegotiatedContentResult <AppTaskLanguage>;
                    Assert.IsNotNull(appTaskLanguageRet4);

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