public void Approved_ShouldReturnViewResultWithAllApprovedBookingsForCurrentHost() { //Arrange var userId = "id"; var expectedPicUrl = "pic"; var expectedBookings = new List <HostBookingsServiceModel> { new HostBookingsServiceModel { CheckInDate = DateTime.UtcNow.AddDays(10), CheckOutDate = DateTime.UtcNow.AddDays(11), GuestId = "guest", GuestProfilePictureUrl = expectedPicUrl, GuestUsername = "******", Id = 1, TotalPrice = 10 } }; var userManager = UserManagerMock.New; userManager .Setup(um => um.GetUserId(It.IsAny <ClaimsPrincipal>())) .Returns(userId); var pictureService = PictureServiceMock.New; pictureService .Setup(ps => ps.PreparePictureToDisplay(It.IsAny <string>())) .Returns(expectedPicUrl); var bookingService = BookingServiceMock.New; bookingService .Setup(bs => bs.HostBookings(It.IsAny <int>(), It.IsAny <int>(), It.Is <string>(id => id == userId), true)) .Returns(expectedBookings); var controller = new BookingsController(bookingService.Object, userManager.Object, pictureService.Object); //Act var result = controller.Approved(); //Assert result .Should() .BeOfType <ViewResult>() .Subject .Model .Should() .Match(m => m.As <HostBookingsViewModel>().Bookings.Equals(expectedBookings)); }
public void Approved_ShouldReturnAllApprovedBookingsForCurrentUser() { //Arrange var userId = "id"; var expectedBookings = new List <GuestBookingServiceModel> { new GuestBookingServiceModel { CheckInDate = DateTime.MinValue, CheckOutDate = DateTime.MaxValue, GuestId = userId, GuestUsername = "******", HomeId = 1, OwnerUsername = "******", PricePerNight = 10, TotalPrice = 10000000 } }; var userManager = UserManagerMock.New; userManager .Setup(um => um.GetUserId(It.IsAny <ClaimsPrincipal>())) .Returns(userId); var bookingService = BookingServiceMock.New; bookingService .Setup(bs => bs.GuestBookings(It.Is <string>(id => id == userId), true)) .Returns(expectedBookings); var controller = new BookingsController(bookingService.Object, null, userManager.Object); //Act var result = controller.Approved(); //Assert result .Should() .BeOfType <ViewResult>() .Subject .Model .Should() .Match(m => m.As <IEnumerable <GuestBookingServiceModel> >().Equals(expectedBookings)); }