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

                    Address addressLast = new Address();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        AddressService addressService = new AddressService(query, db, ContactID);
                        addressLast = (from c in db.Addresses select c).FirstOrDefault();
                    }

                    // ok with Address info
                    IHttpActionResult jsonRet = addressController.GetAddressWithID(addressLast.AddressID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <Address> Ret = jsonRet as OkNegotiatedContentResult <Address>;
                    Address addressRet = Ret.Content;
                    Assert.AreEqual(addressLast.AddressID, addressRet.AddressID);

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

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

                    OkNegotiatedContentResult <Address> addressRet2 = jsonRet2 as OkNegotiatedContentResult <Address>;
                    Assert.IsNotNull(addressRet2);

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

                    // Put to return CSSPError because AddressID of 0 does not exist
                    addressRet.AddressID = 0;
                    IHttpActionResult jsonRet3 = addressController.Put(addressRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <Address> addressRet3 = jsonRet3 as OkNegotiatedContentResult <Address>;
                    Assert.IsNull(addressRet3);

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

                    Address addressFirst = new Address();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        AddressService addressService = new AddressService(new Query(), db, ContactID);
                        addressFirst = (from c in db.Addresses select c).FirstOrDefault();
                    }

                    // ok with Address info
                    IHttpActionResult jsonRet = addressController.GetAddressWithID(addressFirst.AddressID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <Address> Ret = jsonRet as OkNegotiatedContentResult <Address>;
                    Address addressRet = Ret.Content;
                    Assert.AreEqual(addressFirst.AddressID, addressRet.AddressID);

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

                    // Not Found
                    IHttpActionResult jsonRet2 = addressController.GetAddressWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <Address> addressRet2 = jsonRet2 as OkNegotiatedContentResult <Address>;
                    Assert.IsNull(addressRet2);

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

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

                        AddressService addressService = new AddressService(query, db, ContactID);
                        addressLast = (from c in db.Addresses select c).FirstOrDefault();
                    }

                    // ok with Address info
                    IHttpActionResult jsonRet = addressController.GetAddressWithID(addressLast.AddressID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <Address> Ret = jsonRet as OkNegotiatedContentResult <Address>;
                    Address addressRet = Ret.Content;
                    Assert.AreEqual(addressLast.AddressID, addressRet.AddressID);

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

                    // Post to return CSSPError because AddressID exist
                    IHttpActionResult jsonRet2 = addressController.Post(addressRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <Address> addressRet2 = jsonRet2 as OkNegotiatedContentResult <Address>;
                    Assert.IsNull(addressRet2);

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

                    // Post to return newly added Address
                    addressRet.AddressID                 = 0;
                    addressController.Request            = new System.Net.Http.HttpRequestMessage();
                    addressController.Request.RequestUri = new System.Uri("http://localhost:5000/api/address");
                    IHttpActionResult jsonRet3 = addressController.Post(addressRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <Address> addressRet3 = jsonRet3 as CreatedNegotiatedContentResult <Address>;
                    Assert.IsNotNull(addressRet3);

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

                    IHttpActionResult jsonRet4 = addressController.Delete(addressRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <Address> addressRet4 = jsonRet4 as OkNegotiatedContentResult <Address>;
                    Assert.IsNotNull(addressRet4);

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