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

                    Infrastructure infrastructureLast = new Infrastructure();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        InfrastructureService infrastructureService = new InfrastructureService(query, db, ContactID);
                        infrastructureLast = (from c in db.Infrastructures select c).FirstOrDefault();
                    }

                    // ok with Infrastructure info
                    IHttpActionResult jsonRet = infrastructureController.GetInfrastructureWithID(infrastructureLast.InfrastructureID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <Infrastructure> Ret = jsonRet as OkNegotiatedContentResult <Infrastructure>;
                    Infrastructure infrastructureRet = Ret.Content;
                    Assert.AreEqual(infrastructureLast.InfrastructureID, infrastructureRet.InfrastructureID);

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

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

                    OkNegotiatedContentResult <Infrastructure> infrastructureRet2 = jsonRet2 as OkNegotiatedContentResult <Infrastructure>;
                    Assert.IsNotNull(infrastructureRet2);

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

                    // Put to return CSSPError because InfrastructureID of 0 does not exist
                    infrastructureRet.InfrastructureID = 0;
                    IHttpActionResult jsonRet3 = infrastructureController.Put(infrastructureRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <Infrastructure> infrastructureRet3 = jsonRet3 as OkNegotiatedContentResult <Infrastructure>;
                    Assert.IsNull(infrastructureRet3);

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

                    Infrastructure infrastructureFirst = new Infrastructure();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        InfrastructureService infrastructureService = new InfrastructureService(new Query(), db, ContactID);
                        infrastructureFirst = (from c in db.Infrastructures select c).FirstOrDefault();
                    }

                    // ok with Infrastructure info
                    IHttpActionResult jsonRet = infrastructureController.GetInfrastructureWithID(infrastructureFirst.InfrastructureID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <Infrastructure> Ret = jsonRet as OkNegotiatedContentResult <Infrastructure>;
                    Infrastructure infrastructureRet = Ret.Content;
                    Assert.AreEqual(infrastructureFirst.InfrastructureID, infrastructureRet.InfrastructureID);

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

                    // Not Found
                    IHttpActionResult jsonRet2 = infrastructureController.GetInfrastructureWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <Infrastructure> infrastructureRet2 = jsonRet2 as OkNegotiatedContentResult <Infrastructure>;
                    Assert.IsNull(infrastructureRet2);

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

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

                        InfrastructureService infrastructureService = new InfrastructureService(query, db, ContactID);
                        infrastructureLast = (from c in db.Infrastructures select c).FirstOrDefault();
                    }

                    // ok with Infrastructure info
                    IHttpActionResult jsonRet = infrastructureController.GetInfrastructureWithID(infrastructureLast.InfrastructureID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <Infrastructure> Ret = jsonRet as OkNegotiatedContentResult <Infrastructure>;
                    Infrastructure infrastructureRet = Ret.Content;
                    Assert.AreEqual(infrastructureLast.InfrastructureID, infrastructureRet.InfrastructureID);

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

                    // Post to return CSSPError because InfrastructureID exist
                    IHttpActionResult jsonRet2 = infrastructureController.Post(infrastructureRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <Infrastructure> infrastructureRet2 = jsonRet2 as OkNegotiatedContentResult <Infrastructure>;
                    Assert.IsNull(infrastructureRet2);

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

                    // Post to return newly added Infrastructure
                    infrastructureRet.InfrastructureID          = 0;
                    infrastructureController.Request            = new System.Net.Http.HttpRequestMessage();
                    infrastructureController.Request.RequestUri = new System.Uri("http://localhost:5000/api/infrastructure");
                    IHttpActionResult jsonRet3 = infrastructureController.Post(infrastructureRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <Infrastructure> infrastructureRet3 = jsonRet3 as CreatedNegotiatedContentResult <Infrastructure>;
                    Assert.IsNotNull(infrastructureRet3);

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

                    IHttpActionResult jsonRet4 = infrastructureController.Delete(infrastructureRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <Infrastructure> infrastructureRet4 = jsonRet4 as OkNegotiatedContentResult <Infrastructure>;
                    Assert.IsNotNull(infrastructureRet4);

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