Beispiel #1
0
        public async void ApproveSessionRequest_Returns_OkObjectResult_With_Approved_SessionRequestDto()
        {
            var userId    = Guid.NewGuid();
            var roomId    = Guid.NewGuid();
            var startTime = DateTime.Now;
            var endTime   = startTime.AddHours(2);

            _identity.Setup(i => i.IsAuthenticated).Returns(true);
            _identity.Setup(i => i.Name).Returns(userId.ToString());

            var room = new RoomDto
            {
                Id = roomId
            };

            var expectedModel = new SessionRequestDto
            {
                Id               = Guid.NewGuid(),
                RoomId           = roomId,
                RequestingUserId = userId,
                RequestedTime    = new DateRangeDto {
                    Start = startTime, End = endTime
                },
                SessionRequestStatusId = (int)SessionRequestStatusId.Approved
            };

            _roomService
            .Setup(s => s.GetAsync(It.IsAny <Guid>()))
            .Returns(Task.FromResult(room));

            _roomService
            .Setup(s => s.ApproveSessionRequestAsync(It.IsAny <Guid>(), It.IsAny <Guid>()))
            .Returns(Task.FromResult(expectedModel));

            var result = await _roomsController.ApproveSessionRequest(roomId, expectedModel.Id);

            Assert.IsType <OkObjectResult>(result);

            var okResult = result as OkObjectResult;

            Assert.IsType <SessionRequestDto>(okResult.Value);

            var actual = okResult.Value as SessionRequestDto;

            Assert.Equal(expectedModel.SessionRequestStatusId, actual.SessionRequestStatusId);
        }