public async Task CanRemoveCarrier() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyProducerBusiness(); var contact = ObjectFactory.CreateEmptyContact(); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var carrierCollection = new CarrierCollection(notification.Id); context.Carriers.Add(carrierCollection); await context.SaveChangesAsync(); var carrier = carrierCollection.AddCarrier(business, address, contact); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); Assert.True(carrierCollection.Carriers.Any()); carrierCollection.RemoveCarrier(carrier.Id); await context.SaveChangesAsync(); Assert.False(carrierCollection.Carriers.Any()); }
public async Task CanAddMultipleCarriers() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyProducerBusiness(); var contact = ObjectFactory.CreateEmptyContact(); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var carrierCollection = new CarrierCollection(notification.Id); context.Carriers.Add(carrierCollection); await context.SaveChangesAsync(); for (int i = 0; i < 5; i++) { carrierCollection.AddCarrier(business, address, contact); } await context.SaveChangesAsync(); Assert.Equal(carrierCollection.Carriers.Count(), 5); }
private void AddCarrier() { var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyBusiness(); var contact = ObjectFactory.CreateEmptyContact(); carrierCollection.AddCarrier(business, address, contact); }
public async Task CopyAsync(IwsContext context, Guid notificationSourceId, Guid notificationDestinationId) { var originalCarriers = await context.Carriers .AsNoTracking() .Include("CarriersCollection") .SingleOrDefaultAsync(c => c.NotificationId == notificationSourceId); var newCarriers = new CarrierCollection(notificationDestinationId); if (originalCarriers != null) { foreach (var carrier in originalCarriers.Carriers) { var newCarrier = newCarriers.AddCarrier(carrier.Business, carrier.Address, carrier.Contact); } } context.Carriers.Add(newCarriers); }
public async Task CanRemoveCarrier() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyProducerBusiness(); var contact = ObjectFactory.CreateEmptyContact(); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var carrierCollection = new CarrierCollection(notification.Id); context.Carriers.Add(carrierCollection); await context.SaveChangesAsync(); var carrier = carrierCollection.AddCarrier(business, address, contact); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); Assert.True(carrierCollection.Carriers.Any()); carrierCollection.RemoveCarrier(carrier.Id); await context.SaveChangesAsync(); Assert.False(carrierCollection.Carriers.Any()); context.DeleteOnCommit(notification); context.DeleteOnCommit(carrierCollection); await context.SaveChangesAsync(); }
public async Task CanAddMultipleCarriers() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyProducerBusiness(); var contact = ObjectFactory.CreateEmptyContact(); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var carrierCollection = new CarrierCollection(notification.Id); context.Carriers.Add(carrierCollection); await context.SaveChangesAsync(); for (int i = 0; i < 5; i++) { carrierCollection.AddCarrier(business, address, contact); } await context.SaveChangesAsync(); Assert.Equal(carrierCollection.Carriers.Count(), 5); context.DeleteOnCommit(notification); context.DeleteOnCommit(carrierCollection); await context.SaveChangesAsync(); }