public async Task GetNotificationProducerByIdChecksAuthorization() { var notification = NotificationApplicationFactory.Create(userId, NotificationType.Recovery, UKCompetentAuthority.England, 20181); context.NotificationApplications.Add(notification); context.SaveChanges(); var notificationId = notification.Id; var producerCollection = new ProducerCollection(notificationId); producerCollection.AddProducer(ObjectFactory.CreateEmptyProducerBusiness(), ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact()); context.Producers.Add(producerCollection); context.SaveChanges(); var repository = new ProducerRepository(context, notificationApplicationAuthorization); await repository.GetByNotificationId(notificationId); A.CallTo(() => notificationApplicationAuthorization.EnsureAccessAsync(notificationId)).MustHaveHappened(); context.DeleteOnCommit(producerCollection); await context.SaveChangesAsync(); context.DeleteOnCommit(notification); await context.SaveChangesAsync(); }