Beispiel #1
0
        public HttpResponseMessage GetAssociates()
        {
            IEnumerable <AssociateModel> result = null;

            try
            {
                var res = _associatesService.GetAllAssociates();
                result = Helper.CastObject <IEnumerable <AssociateModel> >(res);
            }
            catch (Exception ex)
            {
                _logManager.WriteLog(ex);
            }
            return(ToJson(result));
        }
Beispiel #2
0
        public void GetAllAssociates()
        {
            var associatesList = associatesService.GetAllAssociates().ToList();

            if (associatesList == null)
            {
                Assert.Null(associatesList);
            }
            Assert.NotNull(associatesList);
            Assert.GreaterOrEqual(associatesList.Count(), 0);
        }
Beispiel #3
0
        public void UpdateAssociateTest()
        {
            var associate = _associatesService.GetAllAssociates().Where(a => a.Associate_Id == 575566).FirstOrDefault();
            var response  = new AssociateModel();
            var request   = Helper.CastObject <AssociateModel>(associate);

            request.Name = "TestAssociateUpdated";
            var associateController = new AssociateController(_associatesService, _logManager)
            {
                Request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(ServiceBaseURL + "associate/updateAssociate")
                }
            };

            associateController.Configuration = new HttpConfiguration();
            _response = associateController.UpdateAssociate(request);
            response  = JsonConvert.DeserializeObject <AssociateModel>(_response.Content.ReadAsStringAsync().Result);
            Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(response != null, true);
            Assert.AreEqual(response.Name, "TestAssociateUpdated");
        }