public async Task SetStatus_UserIsNotCreator_ThrowsInsufficientRightsException() { var loggedInUserId = _emptyUserId; var tpRepo = _mockRepo.Create <ITravelPlanRepository>(); var userRepo = _mockRepo.Create <IUserRepository>(); var userTPService = _mockRepo.Create <IUserTravelPlanService>(); var tpStatusService = _mockRepo.Create <ITravelPlanStatusService>(); int status = (int)TravelPlanStatusEnum.Archived; var tpToEdit = new Models.TravelPlan() { CreatedById = Guid.NewGuid() }; //arrange tpRepo.Setup((tpr) => tpr.GetAsync(It.IsAny <Guid>(), false)).ReturnsAsync(tpToEdit); //act using (var context = new AppDbContext(_dbOptions)) { var tpService = new TravelPlanService(tpRepo.Object, userRepo.Object, userTPService.Object, tpStatusService.Object, context); var result = await tpService.SetStatusAsync(loggedInUserId, _emptyUserId, status); } }
public async Task SetStatus_InvalidStatus_ThrowsException() { var loggedInUserId = _emptyUserId; var tpRepo = _mockRepo.Create <ITravelPlanRepository>(); var userRepo = _mockRepo.Create <IUserRepository>(); var userTPService = _mockRepo.Create <IUserTravelPlanService>(); var tpStatusService = _mockRepo.Create <ITravelPlanStatusService>(); int invalidStatus = 123; //act using (var context = new AppDbContext(_dbOptions)) { var tpService = new TravelPlanService(tpRepo.Object, userRepo.Object, userTPService.Object, tpStatusService.Object, context); var result = await tpService.SetStatusAsync(loggedInUserId, _emptyUserId, invalidStatus); } }