//TODO: write new integration tests that test the creation, updation and deletion of waste recovery and disposal information. private async Task <NotificationApplication> CreateNotification() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); return(notification); }
public async Task CanUpdateStateOfExport() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Disposal, UKCompetentAuthority.England, 450); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var transport = new TransportRoute(notification.Id); context.TransportRoutes.Add(transport); await context.SaveChangesAsync(); var exitPoint = context.EntryOrExitPoints.First(); var country = exitPoint.Country; var competentAuthority = context.CompetentAuthorities.First(ca => ca.Country.Id == country.Id); var stateOfExport = new StateOfExport(country, competentAuthority, exitPoint); IntraCountryExportAllowed[] intraCountryExportAlloweds = new IntraCountryExportAllowed[0]; A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, stateOfExport)).Returns(true); transport.SetStateOfExportForNotification(stateOfExport, this.validator); await context.SaveChangesAsync(); var nextExitPoint = context.EntryOrExitPoints.First(ep => ep.Id != exitPoint.Id); if (nextExitPoint.Country.Id != country.Id) { country = nextExitPoint.Country; competentAuthority = context.CompetentAuthorities.First(ca => ca.Country.Id == country.Id); } var newStateOfExport = new StateOfExport(country, competentAuthority, nextExitPoint); A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, newStateOfExport)).Returns(true); transport.SetStateOfExportForNotification(newStateOfExport, this.validator); await context.SaveChangesAsync(); Assert.Equal(nextExitPoint.Id, transport.StateOfExport.ExitPoint.Id); DatabaseDataDeleter.DeleteDataForNotification(notification.Id, context); }