Exemplo n.º 1
0
        public void FetchPastEvents_FakePastEventResponseModel_ReturnsPastEventResponseModel()
        {
            //Arrange
            var pastEvent_Db = new Mock <IPastEvent>();

            pastEvent_Db.Setup(m => m.fetchPastEventAttendeesData(It.IsAny <int>())).Returns(getPastEventResponseModelData());
            var pastEvent_BAL = new FetchPastEvents(pastEvent_Db.Object);
            //Act
            var actual   = pastEvent_BAL.fetchPastEventAttendeesData(It.IsAny <int>());
            var expected = getPastEventResponseModelData();

            //Assert
            CollectionAssert.Equals(actual, expected);
        }
Exemplo n.º 2
0
        public void FetchPastEvents_PastEventResponseModel_ReturnsNull()
        {
            //Arrange
            var pastEvent_Db = new Mock <IPastEvent>();
            List <PastEventResponseModel> pastEventResponseModelList = null;

            pastEvent_Db.Setup(m => m.fetchPastEventAttendeesData(It.IsAny <int>())).Returns(pastEventResponseModelList);
            var pastEvent_BAL = new FetchPastEvents(pastEvent_Db.Object);
            //Act
            var actual = pastEvent_BAL.fetchPastEventAttendeesData(It.IsAny <int>());
            List <PastEventResponseModel> expected = null;

            //Assert
            CollectionAssert.Equals(actual, expected);
        }
 public HttpResponseMessage PastEventAttendees(int userId)
 {
     try
     {
         var pastEventAttendeesData = FetchPastEvents.fetchPastEventAttendeesData(userId);
         if (pastEventAttendeesData != null)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, pastEventAttendeesData));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.Created, new { Status = false }));
         }
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, "Error"));
     }
 }