예제 #1
0
        public void GetAll_Seats_By_Auditorium_Id()
        {
            //Arrange
            int expectedStatusCode = 200;
            int expectedRow        = 3;
            int expectedNumber     = 2;

            SeatDomainModel seatDomainModel = new SeatDomainModel
            {
                Id           = Guid.NewGuid(),
                AuditoriumId = 23,
                Number       = 2,
                Row          = 3
            };

            List <SeatDomainModel> seatDomainModels = new List <SeatDomainModel>();

            seatDomainModels.Add(seatDomainModel);


            IEnumerable <SeatDomainModel> listOfSeatsIEn = seatDomainModels;

            Task <IEnumerable <SeatDomainModel> > responseTask = Task.FromResult(listOfSeatsIEn);

            _seatService        = new Mock <ISeatService>();
            _reservationService = new Mock <IReservationService>();
            _seatService.Setup(x => x.GetAllSeatsByAuditoriumId(It.IsAny <int>())).Returns(responseTask);
            SeatsController seatsController = new SeatsController(_seatService.Object, _reservationService.Object);

            //Act
            var result       = seatsController.GetAllSeatsByAuditoriumId(1).ConfigureAwait(false).GetAwaiter().GetResult().Result;
            var objectResult = ((OkObjectResult)result).Value;
            List <SeatDomainModel> seatsResult = (List <SeatDomainModel>)objectResult;

            //Assert
            Assert.IsNotNull(objectResult);
            Assert.AreEqual(expectedRow, seatsResult[0].Row);
            Assert.AreEqual(expectedNumber, seatsResult[0].Number);
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));
            Assert.AreEqual(expectedStatusCode, ((OkObjectResult)result).StatusCode);
        }
예제 #2
0
        public void GetAll_Seats_By_Auditorium_Id_Return_Not_Found()
        {
            //Arrange
            int expectedStatusCode = 404;

            IEnumerable <SeatDomainModel> listOfSeatsIEn = null;

            Task <IEnumerable <SeatDomainModel> > responseTask = Task.FromResult(listOfSeatsIEn);

            _seatService        = new Mock <ISeatService>();
            _reservationService = new Mock <IReservationService>();
            _seatService.Setup(x => x.GetAllSeatsByAuditoriumId(It.IsAny <int>())).Returns(responseTask);
            SeatsController seatsController = new SeatsController(_seatService.Object, _reservationService.Object);

            //Act
            var    result       = seatsController.GetAllSeatsByAuditoriumId(1).ConfigureAwait(false).GetAwaiter().GetResult().Result;
            var    objectResult = ((NotFoundObjectResult)result).Value;
            string seatsResult  = (string)objectResult;

            //Assert
            Assert.IsNotNull(objectResult);
            Assert.IsInstanceOfType(result, typeof(NotFoundObjectResult));
            Assert.AreEqual(expectedStatusCode, ((NotFoundObjectResult)result).StatusCode);
        }