public IHttpActionResult Get([FromUri] NotesSearchCriteria criteria)
 {
     //try
     //{
     if (criteria == null)
     {
         return(BadRequest("No Parameter found"));
     }
     //else if (criteria.DealNumber < 1)
     //{
     //    return StatusCode(HttpStatusCode.BadRequest);
     //}
     else
     {
         //EntityResult<IEnumerable<BLL_DealNotes>> dataresult = EntityManager.GetNotes(criteria.DealNumber);
         //if(dataresult.Data.IsNullOrEmpty())
         //{
         //   return StatusCode(HttpStatusCode.NotFound);
         //}
         //return this.GetResponse(EntityManager.GetNotes(criteria.DealNumber));
         return(this.GetResponse(EntityManager.GetNotes(criteria.DealNumber)));
     }
     //}
     //catch
     //{
     //    return StatusCode(HttpStatusCode.InternalServerError);
     //}
 }
Beispiel #2
0
        public void NotesController_Get_Returns_BadResponse(NotesSearchCriteria criteria)
        {
            #region Arrange

            SetupUserIdentity();

            //Build response
            var dealNotesRepository = new Mock <INotesRepository>();

            //Build response
            IList <Data.Models.grs_VGrsNote> dealDbData = new List <Data.Models.grs_VGrsNote>
            {
                new Data.Models.grs_VGrsNote
                {
                    Notenum    = 698,
                    Dealnum    = 233,
                    Notedate   = Convert.ToDateTime("2001-06-19 00:00:00.000"),
                    Notes      = "Left message for John Kenney to let him no that we would most likely not be able to quote on the submission due the relatively small size of the deal, and the amount of risk transfer that appeared that they were looking for (in the slip: winner take all w/ no agg limit)",
                    Notetype   = 22,
                    Whoentered = 8069,
                    Name       = "Chris Downey",
                    FirstName  = "Chris",
                    MiddleName = null,
                    LastName   = "Downey"
                }
            };


            // Search method
            dealNotesRepository.Setup(p => p.GetMany(It.IsAny <Expression <Func <grs_VGrsNote, bool> > >())).Returns(dealDbData);
            //Manager
            //DealNotesManager dealNotesManager = new DealNotesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealNotesRepository.Object,transformationManager, new Mock<IPersonProfileManager>().Object);
            NotesManager dealNotesManager = new NotesManager(userManager.Object, cacheStoreManager.Object, mockLogManager.Object, dealNotesRepository.Object, transformationManager, new Mock <ITbDealNotesRepository>().Object);

            var             httpRequest         = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.NotesRoutePrefix}");
            NotesController dealNotesController = CreateDealNotesController(httpRequest, new Mock <INotesRepository>().Object);
            #endregion

            #region Act

            var response = dealNotesController.Get(criteria) as BadRequestErrorMessageResult;
            #endregion

            #region Assert

            string expectedMessage = "No Parameter found";
            Assert.IsInstanceOf <BadRequestErrorMessageResult>(response);
            Assert.AreEqual(expectedMessage, response.Message);

            #endregion
        }
Beispiel #3
0
        public void NotesController_Get_Returns_OKResponseCode(NotesSearchCriteria criteria)
        {
            #region Arrange

            SetupUserIdentity();

            //Create mock repository
            var dealNotesRepository = new Mock <INotesRepository>();

            //Build response
            IList <Data.Models.grs_VGrsNote> dealDbData = new List <Data.Models.grs_VGrsNote>
            {
                new Data.Models.grs_VGrsNote
                {
                    Notenum    = 698,
                    Dealnum    = 233,
                    Notedate   = Convert.ToDateTime("2001-06-19 00:00:00.000"),
                    Notes      = "Left message for John Kenney to let him no that we would most likely not be able to quote on the submission due the relatively small size of the deal, and the amount of risk transfer that appeared that they were looking for (in the slip: winner take all w/ no agg limit)",
                    Notetype   = 22,
                    Whoentered = 8069,
                    Name       = "Chris Downey",
                    FirstName  = "Chris",
                    MiddleName = null,
                    LastName   = "Downey"
                }
            };

            // Search method
            dealNotesRepository.Setup(p => p.GetNotes(criteria.DealNumber)).Returns(dealDbData);

            var             httpRequest         = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), $"{AppSettings.BASEURL}{RouteHelper.NotesRoutePrefix}");
            NotesController dealNotesController = CreateDealNotesController(httpRequest, dealNotesRepository.Object);

            #endregion

            #region Act

            //var response = dealNotesController.Get(criteria);

            //DealNotesSearchCriteria dsc = new DealNotesSearchCriteria { DealNumber = 233 };
            var response = dealNotesController.Get(criteria);

            //var response = dealNotesController.Get(It.IsAny<DealNotesSearchCriteria>());
            var contentResult = response as NegotiatedContentResult <ResponseCollection <Notes> >;

            #endregion

            #region Assert

            #region Expected

            var expectedDealNotes = new Notes
            {
                Notenum    = 698,
                DealNumber = 233,
                Notedate   = Convert.ToDateTime("2001-06-19 00:00:00.000"),
                NoteText   = "Left message for John Kenney to let him no that we would most likely not be able to quote on the submission due the relatively small size of the deal, and the amount of risk transfer that appeared that they were looking for (in the slip: winner take all w/ no agg limit)",
                Notetype   = 22,
                Whoentered = 8069,
                Name       = "Chris Downey",
                FirstName  = "Chris",
                MiddleName = null,
                LastName   = "Downey"
            };

            var expectedGetLink = new Link(LinkType.RelatedEntity, EntityType.Notes, $"v1/notes?dealnumber={expectedDealNotes.DealNumber}", HttpMethodType.GET);

            #endregion
            Assertions.AssertOkResponse(contentResult);

            var summaryData = contentResult.Content.results;

            for (int i = 0; i <= summaryData.Count - 1; i++)
            {
                //Data
                var actualDealNotes = summaryData[i].data;

                Assertions.AssertData(expectedDealNotes, actualDealNotes);

                // Links & Messages
                //Assert.Multiple(() =>
                //{
                //    Assert.IsNotEmpty(summaryData[i].links);
                //    Assert.AreEqual(1, summaryData[i].links.Count);
                //    Assertions.AssertLink(expectedGetLink, summaryData[i].links[0]);
                //});

                Assert.IsEmpty(summaryData[i].messages);
            }

            #endregion
        }