public async Task <Guid> HandleAsync(CreateLegacyNotificationApplication message) { var notification = await notificationApplicationFactory.CreateLegacy( message.NotificationType, message.CompetentAuthority, message.Number); notificationApplicationRepository.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); var carrierCollection = new CarrierCollection(notification.Id); var producerCollection = new ProducerCollection(notification.Id); facilityRepository.Add(facilityCollection); carrierRepository.Add(carrierCollection); producerRepository.Add(producerCollection); await context.SaveChangesAsync(); return(notification.Id); }
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); }
public void Setup() { environment = new SimulationEnvironment { LightPosition = new Vertex(0, 10000, 0), Temperature = 22 }; plant = TestPlant.CreatePlant(); cellFactory = new GenericCellFactory(); optionsService = PlantSimulatorOptionsHelper.CreateOptionsService(); divider = new GenericCellDivider(cellFactory); helper = new GeometryHelper(); cellSizer = new GenericCellSizer(helper, new LoggerAdapter <GenericCellSizer>(new NullLogger <GenericCellSizer>())); cellCollisionDetection = new CellCollisionDetection(helper); bodySystemSolver = new GenericCellBodySystemSolver(cellCollisionDetection, cellSizer); cellGrower = new GenericCellGrower(plant, environment, bodySystemSolver, optionsService); descriptorService = new PlantDescriptorService(); cellCreator = new HexagonCellCreator(cellFactory); gridCreator = new HexagonalCellGridFactory(cellCreator, CornCellTypeLocator.GetCornCellTypeLocator(), optionsService); plantPartCellCreator = new PlantPartCellCreator(gridCreator); internodePartFactory = new GenericInternodePartFactory(optionsService, gridCreator); stemPartFactory = new GenericStemPartFactory(optionsService, internodePartFactory); petiolePartFactory = new GenericPetiolePartFactory(cellFactory, optionsService); nodePartFactory = new GenericNodePartFactory(optionsService, cellFactory, stemPartFactory, petiolePartFactory); internodePlantPartDevelopment = new InternodePartDevelopment(optionsService, nodePartFactory, cellGrower, descriptorService, internodePartFactory); rootFactory = new GenericRootPartFactory(optionsService, plantPartCellCreator); rootPlantPartDevelopment = new RootPartDevelopment(optionsService, nodePartFactory, rootFactory, cellGrower, descriptorService); developer = new PlantPartDeveloper(internodePlantPartDevelopment, rootPlantPartDevelopment); sucroseCarrierCollection = new SucroseCarrierCollection( new LoggerAdapter <SucroseCarrierCollection>(new NullLogger <SucroseCarrierCollection>())); sucroseTransporter = new SucroseTransporter(cellCollisionDetection, helper, sucroseCarrierCollection, new LoggerAdapter <FluidTransporter <Sucrose> >(new NullLogger <FluidTransporter <Sucrose> >())); plantGrower = new GenericPlantGrower(bodySystemSolver, developer, sucroseTransporter); runner = new GenericPlantRunner(plant, environment, plantGrower, new FluidsPlantCycle(plant, optionsService, sucroseCarrierCollection, new LoggerAdapter <FluidsPlantCycle>(new NullLogger <FluidsPlantCycle>()))); RangeExtensions.Random = new Random(optionsService.Options.Simulation.RandomSeed); }
public CarrierBlock(IList<MergeField> mergeFields, MeansOfTransport meansOfTransport, CarrierCollection carrierCollection) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); data = CarrierViewModel.CreateCarrierViewModelsForNotification(meansOfTransport, carrierCollection, new MeansOfTransportFormatter()); AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName); }
private void AddCarriers(Guid sourceId, Guid destinationId) { var sourceCarriers = new CarrierCollection(sourceId); var destinationCarriers = new CarrierCollection(destinationId); context.Carriers.Add(sourceCarriers); context.Carriers.Add(destinationCarriers); }
public AddCarrierHandlerTests() { notificationId = Guid.NewGuid(); countryId = Guid.NewGuid(); countryRepository = A.Fake <ICountryRepository>(); repository = A.Fake <ICarrierRepository>(); var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); var carrierCollection = new CarrierCollection(notificationId); A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(carrierCollection); handler = new AddCarrierHandler(context, repository, countryRepository); }
public static IList<CarrierViewModel> CreateCarrierViewModelsForNotification( MeansOfTransport meansOfTransport, CarrierCollection carrierCollection, MeansOfTransportFormatter meansOfTransportFormatter) { if (meansOfTransport == null || carrierCollection == null || carrierCollection.Carriers == null || !carrierCollection.Carriers.Any()) { return new CarrierViewModel[0]; } var meansOfTransportDisplay = meansOfTransportFormatter.MeansOfTransportAsString(meansOfTransport.Route); return carrierCollection.Carriers.Select(c => new CarrierViewModel(c, meansOfTransportDisplay)) .ToArray(); }
public static IList <CarrierViewModel> CreateCarrierViewModelsForNotification( MeansOfTransport meansOfTransport, CarrierCollection carrierCollection, MeansOfTransportFormatter meansOfTransportFormatter) { if (meansOfTransport == null || carrierCollection == null || carrierCollection.Carriers == null || !carrierCollection.Carriers.Any()) { return(new CarrierViewModel[0]); } var meansOfTransportDisplay = meansOfTransportFormatter.MeansOfTransportAsString(meansOfTransport.Route); return(carrierCollection.Carriers.Select(c => new CarrierViewModel(c, meansOfTransportDisplay)) .ToArray()); }
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 override void Transport(IPlantPart part) { if (!part.Cells.Any()) { return; } var inTransit = CarrierCollection.GetInTransit(); foreach (var transit in inTransit) { if (MoveCarrier(transit, part)) { Logger.LogDebug("{Transit} reached goal", transit.Destination.Geometry.TopCenter); // transit.Current.StarchStorage.Amount += transit.Fluid.Amount; CarrierCollection.Delete(transit.Destination); } } }
public async Task <Guid> HandleAsync(CreateNotificationApplication command) { var authority = command.CompetentAuthority; var notification = await notificationApplicationFactory.CreateNew(command.NotificationType, authority); notificationApplicationRepository.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); var carrierCollection = new CarrierCollection(notification.Id); var producerCollection = new ProducerCollection(notification.Id); facilityRepository.Add(facilityCollection); carrierRepository.Add(carrierCollection); producerRepository.Add(producerCollection); await context.SaveChangesAsync(); return(notification.Id); }
public NotificationCarrierTests() { carrierCollection = new CarrierCollection(NotificationId); }
public CarrierBlock(IList <MergeField> mergeFields, MeansOfTransport meansOfTransport, CarrierCollection carrierCollection) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); data = CarrierViewModel.CreateCarrierViewModelsForNotification(meansOfTransport, carrierCollection, new MeansOfTransportFormatter()); AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName); }
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(); }
public void Add(CarrierCollection carrierCollection) { context.Carriers.Add(carrierCollection); }