Example #1
0
        public DIProfilingFixture()
        {
            DIBuilder
            .Continue()

            // Register the factory for the CellProfileAnalyzer for detailed call pass/lift cell profiles
            .Add(x => x.AddTransient <Func <ISiteModel, ISubGridTreeBitMask, IFilterSet, ICellLiftBuilder, IOverrideParameters, ILiftParameters, ICellProfileAnalyzer <ProfileCell> > >(
                     factory => (siteModel, pDExistenceMap, filterSet, cellLiftBuilder, overrides, liftParams)
                     => new CellProfileAnalyzer(siteModel, pDExistenceMap, filterSet, cellLiftBuilder, overrides, liftParams)))

            // Register the factory for the CellProfileAnalyzer for summary volume cell profiles
            .Add(x => x.AddTransient <Func <ISiteModel, ISubGridTreeBitMask, IFilterSet, IDesignWrapper, ICellLiftBuilder, VolumeComputationType, IOverrideParameters, ILiftParameters, ICellProfileAnalyzer <SummaryVolumeProfileCell> > >(
                     factory => (siteModel, pDExistenceMap, filterSet, referenceDesignWrapper, cellLiftBuilder, volumeComputationType, overrides, liftParams)
                     => new SummaryVolumesCellProfileAnalyzer(siteModel, pDExistenceMap, filterSet, referenceDesignWrapper, cellLiftBuilder, volumeComputationType, overrides, liftParams)))

            .Complete();
        }
Example #2
0
        public void CallsRebuildManager_Sync()
        {
            var mockManager = new Mock <ISiteModelRebuilderManager>();

            mockManager.Setup(x => x.Rebuild(It.IsAny <Guid>(), It.IsAny <bool>(), It.IsAny <TransferProxyType>())).Returns(true);

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton(mockManager.Object))
            .Complete();

            var executor = new ProjectRebuildExecutor(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), new Mock <IServiceExceptionHandler>().Object);

            executor.Process(new ProjectRebuildRequest(Guid.NewGuid(), TransferProxyType.TAGFiles, false));

            mockManager.Verify(x => x.Rebuild(It.IsAny <Guid>(), It.IsAny <bool>(), It.IsAny <TransferProxyType>()), Times.Once);
        }
Example #3
0
        private (CellPassesRequest_ApplicationService, FilterSet, Guid) BuildTestDataAndSetAreaFilter()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var baseTime  = DateTime.UtcNow;
            var siteModel = BuildTestSiteModel(baseTime, count: expectedCount);

            var request = new CellPassesRequest_ApplicationService();

            var filter = new FilterSet(new CombinedFilter());

            var fence = new Fence();

            fence.Points.Add(new FencePoint(-115.01912, 36.207522, 0.0));
            fence.Points.Add(new FencePoint(-115.018673, 36.207501, 0.0));
            fence.Points.Add(new FencePoint(-115.018887, 36.207213, 0.0));
            fence.Points.Add(new FencePoint(-115.01932, 36.207325, 0.0));

            filter.Filters[0].SpatialFilter.Fence     = fence;
            filter.Filters[0].SpatialFilter.IsSpatial = true;

            // Mocked ConvertCoordinates expected result.
            var neeCoords = new XYZ[fence.Points.Count];

            neeCoords[0].X = 0;
            neeCoords[0].Y = 0;
            neeCoords[1].X = 0;
            neeCoords[1].Y = 1;
            neeCoords[2].X = 1;
            neeCoords[2].Y = 1;
            neeCoords[3].X = 1;
            neeCoords[3].Y = 0;

            var expectedCoordinateConversionResult = neeCoords.ToCoreX_XYZ();

            var convertCoordinatesMock = new Mock <ICoreXWrapper>();

            convertCoordinatesMock.Setup(x => x.LLHToNEE(It.IsAny <string>(), It.IsAny <CoreXModels.XYZ[]>(), It.IsAny <CoreX.Types.InputAs>()))
            .Returns(expectedCoordinateConversionResult);

            DIBuilder.Continue().Add(x => x.AddSingleton(convertCoordinatesMock.Object)).Complete();

            return(request, filter, siteModel.ID);
        }
Example #4
0
        public void GatewayHelper_NoSiteModel_Fail(Guid projectUid)
        {
            var mockSiteModels = new Mock <ISiteModels>();

            mockSiteModels.Setup(x => x.GetSiteModel(It.IsAny <Guid>(), It.IsAny <bool>())).Returns((ISiteModel)null);

            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <ISiteModels>(mockSiteModels.Object))
            .Complete();

            var ex = Assert.Throws <ServiceException>(() => GatewayHelper.ValidateAndGetSiteModel("ValidateReportData_GriddedNoSiteModel_Fail", projectUid));

            ex.Code.Should().Be(HttpStatusCode.BadRequest);
            ex.GetResult.Code.Should().Be(ContractExecutionStatesEnum.ValidationError);
            ex.GetResult.Message.Should().Be($"ValidateReportData_GriddedNoSiteModel_Fail: SiteModel: {projectUid} not found ");
        }
Example #5
0
 private static void DependencyInjection()
 {
     DIBuilder.New()
     .AddLogging()
     .Add(x => x.AddSingleton <IConfigurationStore, GenericConfiguration>())
     .Build()
     .Add(TRexGridFactory.AddGridFactoriesToDI)
     .Add(VSS.TRex.Storage.Utilities.DIUtilities.AddProxyCacheFactoriesToDI)
     .Add(x => x.AddSingleton <ISubGridCellLatestPassesDataWrapperFactory>(new SubGridCellLatestPassesDataWrapperFactory()))
     .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()))
     .Build()
     .Add(x => x.AddSingleton <ISiteModels>(new SiteModels.SiteModels(StorageMutability.Mutable)))
     .Add(x => x.AddSingleton <ISiteModelFactory>(new SiteModelFactory()))
     .Build()
     .Add(x => x.AddSingleton(new ImmutableClientServer("ProjectExtractor-Immutable")))
     .Add(x => x.AddSingleton(new MutableClientServer("ProjectExtractor-Mutable")))
     .Complete();
 }
Example #6
0
        public void GlobalSetup()
        {
            DIBuilder.New()
            .AddLogging()
            .Add(x => x.AddSingleton <IConfigurationStore, GenericConfiguration>())
            .Add(x => x.AddSingleton <IOptimisedTTMProfilerFactory>(new OptimisedTTMProfilerFactory()))
            .Complete();

            design       = new TTMDesign(SubGridTreeConsts.DefaultCellSize);
            readonly_tin = new TrimbleTINModel();

            readonly_tin.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm");

            //design.LoadFromFile(@"C:\Temp\141020 Finish Surface.ttm"); // 0.5 Mb
            //design.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm"); // 165Mb

            design.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm");
        }
Example #7
0
        public void AcquireIgniteTopologyProjections_FailWithUnknownGrid()
        {
            var igniteMock = new IgniteMock();

            DIBuilder.Continue()
            .Add(TRexGridFactory.AddGridFactoriesToDI)

            // Override the main Ignite grid factory method DI'ed from TRexGridFactory.AddGridFactoriesToDI()
            .Add(x => x.AddSingleton <Func <string, IgniteConfiguration, IIgnite> >(factory => (gridName, cfg) => igniteMock.mockIgnite.Object))
            .Complete();

            string GridName = "TestGrid";
            string Role     = "TestRole";

            Action act = () => new BaseIgniteClass(GridName, Role);

            act.Should().Throw <TRexException>().WithMessage($"{GridName} is an unknown grid to create a reference for.");
        }
Example #8
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static void DependencyInjection()
        {
            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <ITRexGridFactory>(new TRexGridFactory()))
            .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()))
            .Add(x => x.AddSingleton <IExistenceMaps>(new ExistenceMaps()))
            .Add(x => x.AddTransient <ISurveyedSurfaces>(factory => new SurveyedSurfaces()))
            .Add(x => x.AddSingleton <ISurveyedSurfaceFactory>(new SurveyedSurfaceFactory()))
            .Add(x => x.AddSingleton <ISiteModels>(new SiteModels(() => DIContext.Obtain <IStorageProxyFactory>().MutableGridStorage())))
            .Build()
            .Add(x => x.AddSingleton(new MutableClientServer("SurveyedSurfaceManager")))
            .Add(x => x.AddSingleton <IDesignManager>(factory => new DesignManager()))
            .Add(x => x.AddSingleton <ISurveyedSurfaceManager>(factory => new VSS.TRex.SurveyedSurfaces.SurveyedSurfaceManager()))

            .Complete();
        }
Example #9
0
        public void Creation_NoIgnite()
        {
            DIBuilder.Eject(); // Be doubly sure

            Action act = () =>
            {
                var _ = new SiteModelChangeProcessorItemHandler();
            };

            if (DIContext.DefaultIsRequired)
            {
                act.Should().Throw <Exception>().WithMessage("DIContext service provider not available");
            }
            else
            {
                act.Should().Throw <TRexException>().WithMessage("Failed to obtain immutable Ignite reference");
            }
        }
Example #10
0
        private void InjectTAGFileBufferQueueMock(bool result)
        {
            var mockTagFileBufferQueue = new Mock <ITAGFileBufferQueue>();

            mockTagFileBufferQueue.Setup(x => x.Add(It.IsAny <ITAGFileBufferQueueKey>(), It.IsAny <TAGFileBufferQueueItem>())).Returns(result);

            var moqConfiguration = DIContext.Obtain <Mock <IConfigurationStore> >();

            moqConfiguration.Setup(x => x.GetValueBool("ENABLE_DEVICE_GATEWAY", It.IsAny <bool>())).Returns(false);

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton <Func <ITAGFileBufferQueue> >(factory => () => mockTagFileBufferQueue.Object))
            .Add(x => x.AddSingleton <IConfigurationStore>(moqConfiguration.Object))
            .Complete();

            IgniteMock.Mutable.AddApplicationGridRouting <IComputeFunc <SubmitTAGFileRequestArgument, SubmitTAGFileResponse>, SubmitTAGFileRequestArgument, SubmitTAGFileResponse>();
        }
Example #11
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        /// </summary>

        protected override void ConfigureAdditionalServices(IServiceCollection services)
        {
            DIBuilder.New(services)
            .Build()
            .Add(x => x.AddSingleton <ICoreXWrapper, CoreXWrapper>())
            .Add(VSS.TRex.IO.DIUtilities.AddPoolCachesToDI)
            .Add(TRexGridFactory.AddGridFactoriesToDI)
            .Build()
            .Add(x => x.AddSingleton <ISiteModels>(new SiteModels.SiteModels(StorageMutability.Mutable)))

            .Add(x => x.AddSingleton <ISiteModelFactory>(new SiteModelFactory()))
            .Add(x => x.AddSingleton <ISiteModelMetadataManager>(factory => new SiteModelMetadataManager(StorageMutability.Mutable)))

            .Add(x => x.AddSingleton <ISurveyedSurfaceManager>(factory => new SurveyedSurfaceManager(StorageMutability.Mutable)))
            .Add(x => x.AddTransient <IDesigns>(factory => new Designs.Storage.Designs()))
            .Add(x => x.AddSingleton <IDesignManager>(factory => new DesignManager(StorageMutability.Mutable)))
            .Add(x => x.AddSingleton <IDesignChangedEventSender>(new DesignChangedEventSender()))
            .Add(x => x.AddSingleton <IMutabilityConverter>(new MutabilityConverter()))
            .Add(x => x.AddSingleton <ISiteModelAttributesChangedEventSender>(new SiteModelAttributesChangedEventSender()))
            //.Add(x => x.AddSingleton<ISiteModelAttributesChangedEventListener>(new SiteModelAttributesChangedEventListener(TRexGrids.MutableGridName())))
            .Add(ExistenceMaps.ExistenceMaps.AddExistenceMapFactoriesToDI)
            .Add(x => x.AddTransient <ISurveyedSurfaces>(factory => new SurveyedSurfaces.SurveyedSurfaces()))
            .Add(x => x.AddTransient <IAlignments>(factory => new Alignments.Alignments()))
            .Add(x => x.AddSingleton <IAlignmentManager>(factory => new AlignmentManager(StorageMutability.Mutable)))
            .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()))
            .Add(VSS.TRex.Storage.Utilities.DIUtilities.AddProxyCacheFactoriesToDI)
            .Build();

            services.AddServiceDiscovery();
            services.AddSingleton <ITransferProxyFactory, TransferProxyFactory>();

            services.AddOpenTracing(builder =>
            {
                builder.ConfigureAspNetCore(options =>
                {
                    options.Hosting.IgnorePatterns.Add(request => request.Request.Path.ToString() == "/ping");
                });
            });

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton <IMutableClientServer>(new MutableClientServer(new [] { ServerRoles.TAG_PROCESSING_NODE_CLIENT, ServerRoles.RECEIVES_SITEMODEL_CHANGE_EVENTS })))
            .Complete();
        }
Example #12
0
        public void Persist_Successful()
        {
            var projectUid = Guid.NewGuid();

            var csvExportUserPreference = new CSVExportUserPreferences();
            var requestArgument         = new CSVExportRequestArgument
                                          (
                projectUid, new FilterSet(new CombinedFilter()), "the filename",
                CoordType.Northeast, OutputTypes.PassCountLastPass,
                csvExportUserPreference, new List <CSVExportMappedMachine>(), false, false
                                          )
            {
                TRexNodeID = Guid.NewGuid()
            };

            var dataRows = new List <string> {
                "string one", "string two"
            };

            var mockTransferProxy = new Mock <ITransferProxy>();

            mockTransferProxy.Setup(t => t.UploadToBucket(It.IsAny <Stream>(), It.IsAny <string>(), It.IsAny <string>()));
            var mockTransferProxyFactory = new Mock <ITransferProxyFactory>();

            mockTransferProxyFactory.Setup(x => x.NewProxy(It.IsAny <TransferProxyType>())).Returns(mockTransferProxy.Object);

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton(mockTransferProxyFactory.Object))
            .Complete();

            var csvExportFileWriter = new CSVExportFileWriter(requestArgument);
            var s3FullPath          = csvExportFileWriter.PersistResult(dataRows);

            s3FullPath.Should().NotBeNull();
            s3FullPath.Should().Be($"project/{requestArgument.ProjectID}/TRexExport/{requestArgument.FileName}__{requestArgument.TRexNodeID}.zip");

            var projectDir = Path.Combine(Path.GetTempPath(), projectUid.ToString());

            if (Directory.Exists(projectDir))
            {
                Directory.Delete(projectDir, true);
            }
        }
Example #13
0
        /* Settings for Alpha
         * private const string TPAAS_AUTH_URL = "https://identity-stg.trimble.com/i/oauth2";
         * private const string TPAAS_APP_TOKEN = "YjZvSk1WemZ6ajJNUEplQkIyWlVLOUJ4ckZFYTp5MWk1YmZlMjdpQlRQb0VCS2laYXMxM0hacUFh";
         */

        public CoordinateServiceUtilityTests()
        {
            DIBuilder
            .Continue()
            .Add(x => x.AddTransient <ICoordinateServiceUtility, CoordinateServiceUtility>())
            .Add(x => x.AddSingleton <ITPaasProxy, TPaasProxy>())

/*        .Add(x => x.AddHttpClient<ITPaaSClient, TPaaSClient>(client =>
 *        client.BaseAddress = new Uri(TPAAS_AUTH_URL) //Configuration.GetValueString(TPaaSClient.TPAAS_AUTH_URL_ENV_KEY))
 *      ).ConfigurePrimaryHttpMessageHandler(() => new TPaaSApplicationCredentialsRequestHandler
 *        {
 *          TPaaSToken = TPAAS_APP_TOKEN, //Configuration.GetValueString(TPaaSApplicationCredentialsRequestHandler.TPAAS_APP_TOKEN_ENV_KEY),
 *          InnerHandler = new HttpClientHandler()
 *        }))
 *      .Add(x => x.AddTransient(context => new TPaaSAuthenticatedRequestHandler {TPaaSClient = context.GetService<ITPaaSClient>()}))
 *      .Add(x => x.AddSingleton<IConvertCoordinates>(new ConvertCoordinates(new CoreX.Wrapper.CoreX())))
 */
            .Complete();
        }
Example #14
0
 /// <summary>Creates a named module with a root <see cref="DICompileUnit"/> to contain debugging information</summary>
 /// <param name="moduleId">Module name</param>
 /// <param name="context">Context for the module</param>
 /// <param name="language">Language to store in the debugging information</param>
 /// <param name="srcFilePath">path of source file to set for the compilation unit</param>
 /// <param name="producer">Name of the application producing this module</param>
 /// <param name="optimized">Flag to indicate if the module is optimized</param>
 /// <param name="compilationFlags">Additional flags</param>
 /// <param name="runtimeVersion">Runtime version if any (use 0 if the runtime version has no meaning)</param>
 public NativeModule(string moduleId
                     , Context context
                     , SourceLanguage language
                     , string srcFilePath
                     , string producer
                     , bool optimized          = false
                     , string compilationFlags = ""
                     , uint runtimeVersion     = 0
                     )
     : this(moduleId, context)
 {
     DICompileUnit = DIBuilder.CreateCompileUnit(language
                                                 , srcFilePath
                                                 , producer
                                                 , optimized
                                                 , compilationFlags
                                                 , runtimeVersion
                                                 );
 }
Example #15
0
 private static void DependencyInjection()
 {
     DIBuilder
     .New()
     .AddLogging()
     .Add(x => x.AddSingleton <ITRexGridFactory>(new TRexGridFactory()))
     .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()))
     .Add(x => x.AddTransient <ISurveyedSurfaces>(factory => new SurveyedSurfaces()))
     .Add(x => x.AddSingleton <ISurveyedSurfaceFactory>(new SurveyedSurfaceFactory()))
     .Build()
     .Add(x => x.AddSingleton <ISiteModels>(new SiteModels(() => DIContext.Obtain <IStorageProxyFactory>().MutableGridStorage())))
     .Add(x => x.AddSingleton <ISiteModelFactory>(new SiteModelFactory()))
     .Add(x => x.AddSingleton <ICoordinateConversion>(new CoordinateConversion()))
     .Add(x => x.AddSingleton(Configuration))
     .Add(x => x.AddSingleton <IExistenceMaps>(new ExistenceMaps()))
     .Add(x => x.AddSingleton <IProductionEventsFactory>(new ProductionEventsFactory()))
     .Add(x => x.AddSingleton(new TagProcComputeServer()))
     .Complete();
 }
Example #16
0
        public void ExecuteTestAsSimpleLoop()
        {
            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <IClass>(new AClass())).Complete();

            var count = 1_000_000_000;
            var sw    = Stopwatch.StartNew();

            for (int i = 0; i < count; i++)
            {
                var di = DIContext.Obtain <IClass>();
            }

            var elapsed = sw.Elapsed;

            Console.WriteLine($"Time to obtain {count} instances from DI: {elapsed}, {elapsed.Ticks / (1.0 * count)} ticks per invocation");
        }
Example #17
0
        static void Main(string[] args)
        {
            Log = Logger.CreateLogger <Program>();
            CultureInfo.DefaultThreadCurrentCulture   = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
            DIBuilder.New().AddLogging().Complete();
            string[] dataList = null;
            try
            {
                if (0 < args.Length)
                {
                    if (args[0].Equals("-a", StringComparison.InvariantCultureIgnoreCase))
                    {
                        PrintAttributes();
                    }
                    else if (Directory.Exists(args[0]))
                    {
                        var directoryToProcess = args[0];
                        if (1 < args.Length)
                        {
                            dataList = new ArraySegment <string>(args, 1, args.Length - 1).ToArray();
                        }

                        ProcessTagFiles(directoryToProcess, dataList);
                    }
                    else
                    {
                        PrintHelp();
                    }
                }
                else
                {
                    PrintHelp();
                }
            }
            catch (Exception e)
            {
                Log.LogCritical(e.ToString());
                Console.WriteLine("An error occured processing input please refer to log file for more details");
                PrintHelp();
            }
        }
Example #18
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        /// </summary>

        protected override void ConfigureAdditionalServices(IServiceCollection services)
        {
            DIBuilder.New(services)
            .Build()
            .Add(x => x.AddSingleton <ICoreXWrapper, CoreXWrapper>())
            .Add(IO.DIUtilities.AddPoolCachesToDI)
            .Add(TRexGridFactory.AddGridFactoriesToDI)
            .Add(Storage.Utilities.DIUtilities.AddProxyCacheFactoriesToDI)
            .Build()
            .Add(x => x.AddSingleton <ISiteModels>(new SiteModels.SiteModels(StorageMutability.Immutable)))
            .Add(x => x.AddSingleton <ISiteModelFactory>(new SiteModelFactory()))

            .Add(x => x.AddSingleton <ISurveyedSurfaceManager>(factory => new SurveyedSurfaceManager(StorageMutability.Immutable)))
            .Add(x => x.AddTransient <IDesigns>(factory => new Designs.Storage.Designs()))
            .Add(x => x.AddSingleton <IDesignManager>(factory => new DesignManager(StorageMutability.Immutable)))
            .Add(x => x.AddTransient <ISurveyedSurfaces>(factory => new SurveyedSurfaces.SurveyedSurfaces()))
            .Add(x => x.AddTransient <IAlignments>(factory => new Alignments.Alignments()))
            .Add(x => x.AddSingleton <IAlignmentManager>(factory => new AlignmentManager(StorageMutability.Immutable)))
            //Monitor number of notifications from this. If too many, go through ignite to get data rather than directly from the site model.
            //.Add(x => x.AddSingleton<ISiteModelAttributesChangedEventListener>(new SiteModelAttributesChangedEventListener(TRexGrids.ImmutableGridName())))
            .Add(x => x.AddSingleton <IClientLeafSubGridFactory>(ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory()))
            .Build();

            services.AddTransient <IErrorCodesProvider, ContractExecutionStatesEnum>();//Replace with custom error codes provider if required
            services.AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>();
            services.AddTransient <IReportDataValidationUtility, ReportDataValidationUtility>();
            services.AddTransient <ICoordinateServiceUtility, CoordinateServiceUtility>();
            services.AddSingleton <IProductionEventsFactory>(new ProductionEventsFactory());
            services.AddSingleton <ITransferProxyFactory, TransferProxyFactory>();

            services.AddOpenTracing(builder =>
            {
                builder.ConfigureAspNetCore(options =>
                {
                    options.Hosting.IgnorePatterns.Add(request => request.Request.Path.ToString() == "/ping");
                });
            });

            DIBuilder.Continue()
            .Add(x => x.AddSingleton <IImmutableClientServer>(new ImmutableClientServer(new [] { "TRexIgniteClient-DotNetStandard", ServerRoles.RECEIVES_SITEMODEL_CHANGE_EVENTS })))
            .Complete();
        }
Example #19
0
        public ProfileBuilderTests_Fixture()
        {
            var factory               = new Mock <IProfilerBuilderFactory <ProfileCell> >();
            var newCellLiftBuilder    = new Mock <ICellLiftBuilder>();
            var newCellProfileBuilder = new Mock <ICellProfileBuilder <ProfileCell> >();
            var newProfileLiftBuilder = new Mock <ICellProfileAnalyzer <ProfileCell> >();

            factory.Setup(mk => mk.NewCellLiftBuilder(null, GridDataType.All, null, null, null))
            .Returns(newCellLiftBuilder.Object);
            factory.Setup(mk => mk.NewCellProfileBuilder(null, null, null, true)).Returns(newCellProfileBuilder.Object);
            factory.Setup(mk => mk.NewCellProfileAnalyzer(ProfileStyle.CellPasses, null, null, null, null, It.IsAny <ICellLiftBuilder>(), It.IsAny <VolumeComputationType>(), null, null))
            .Returns(newProfileLiftBuilder.Object);

            DIBuilder
            .New()
            .Add(x => x.AddSingleton <ICellLiftBuilder>(newCellLiftBuilder.Object))
            .Add(x => x.AddSingleton <ICellProfileBuilder <ProfileCell> >(newCellProfileBuilder.Object))
            .Add(x => x.AddSingleton <ICellProfileAnalyzer <ProfileCell> >(newProfileLiftBuilder.Object))
            .Add(x => x.AddSingleton <IProfilerBuilderFactory <ProfileCell> >(factory.Object)).Complete();
        }
Example #20
0
        public void Heartbeat()
        {
            var configMock = DIContext.Obtain <Mock <IConfigurationStore> >();

            configMock.Setup(x => x.GetValueInt("HEARTBEAT_LOGGER_INTERVAL")).Returns(100);
            configMock.Setup(x => x.GetValueInt("HEARTBEAT_LOGGER_INTERVAL", It.IsAny <int>())).Returns(100);
            DIBuilder.Continue().Add(x => x.AddSingleton(configMock.Object)).Complete();

            var logger    = new TRexHeartBeatLogger();
            var heartbeat = new MemoryHeartBeatLogger();

            var testContext = new object();

            logger.AddContext(heartbeat);

            Thread.Sleep(200);

            logger.RemoveContext(heartbeat);
            logger.Stop();
        }
Example #21
0
        public void ValidateReportData_GriddedSuccess(Guid projectUid, Guid cutFillDesignUid, double?cutFillDesignOffset, Guid?alignmentDesignUid)
        {
            var mockSiteModel  = new Mock <ISiteModel>();
            var mockSiteModels = new Mock <ISiteModels>();

            mockSiteModels.Setup(x => x.GetSiteModel(It.IsAny <Guid>(), It.IsAny <bool>())).Returns(mockSiteModel.Object);

            var mockDesign        = new Mock <IDesign>();
            var mockDesigns       = new Mock <IDesigns>();
            var mockDesignManager = new Mock <IDesignManager>();

            mockDesignManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockDesigns.Object);
            mockDesigns.Setup(x => x.Locate(It.IsAny <Guid>())).Returns(mockDesign.Object);

            var mockAlignments       = new Mock <IAlignments>();
            var mockAlignmentManager = new Mock <IAlignmentManager>();

            mockAlignmentManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockAlignments.Object);
            mockAlignments.Setup(x => x.Locate(It.IsAny <Guid>())).Returns((IAlignment)null);

            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <ISiteModels>(mockSiteModels.Object))
            .Add(x => x.AddSingleton <IDesignManager>(mockDesignManager.Object))
            .Add(x => x.AddSingleton <IAlignmentManager>(mockAlignmentManager.Object))
            .Add(x => x.AddTransient <IReportDataValidationUtility, ReportDataValidationUtility>())
            .Complete();

            var request = new CompactionReportGridTRexRequest(
                projectUid, null,
                true, true, true, true, true, true,
                cutFillDesignUid, cutFillDesignOffset,
                null, GridReportOption.Automatic,
                800000, 400000, 800001, 400001, 2, null, null);

            var siteModel = GatewayHelper.ValidateAndGetSiteModel(nameof(ValidateReportData_GriddedSuccess), projectUid);
            var isOk      = DIContext.Obtain <IReportDataValidationUtility>().ValidateData(nameof(ValidateReportData_GriddedSuccess), projectUid, request);

            Assert.True(isOk);
        }
Example #22
0
        public void ValidateReportData_GriddedNoDesign_Fail(Guid projectUid, Guid cutFillDesignUid, double?cutFillDesignOffset, Guid?alignmentDesignUid)
        {
            var mockSiteModel  = new Mock <ISiteModel>();
            var mockSiteModels = new Mock <ISiteModels>();

            mockSiteModels.Setup(x => x.GetSiteModel(It.IsAny <Guid>(), It.IsAny <bool>())).Returns(mockSiteModel.Object);

            var mockDesigns       = new Mock <IDesigns>();
            var mockDesignManager = new Mock <IDesignManager>();

            mockDesignManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockDesigns.Object);
            mockDesigns.Setup(x => x.Locate(It.IsAny <Guid>())).Returns((IDesign)null);

            var mockAlignments       = new Mock <IAlignments>();
            var mockAlignmentManager = new Mock <IAlignmentManager>();

            mockAlignmentManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockAlignments.Object);
            mockAlignments.Setup(x => x.Locate(It.IsAny <Guid>())).Returns((IAlignment)null);

            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <ISiteModels>(mockSiteModels.Object))
            .Add(x => x.AddSingleton <IDesignManager>(mockDesignManager.Object))
            .Add(x => x.AddSingleton <IAlignmentManager>(mockAlignmentManager.Object))
            .Add(x => x.AddTransient <IReportDataValidationUtility, ReportDataValidationUtility>())
            .Complete();

            var request = new CompactionReportGridTRexRequest(
                projectUid, null,
                true, true, true, true, true, true,
                cutFillDesignUid, cutFillDesignOffset,
                null, GridReportOption.Automatic,
                800000, 400000, 800001, 400001, 2, null, null);

            var ex = Assert.Throws <ServiceException>(() => DIContext.Obtain <IReportDataValidationUtility>().ValidateData(nameof(ValidateReportData_GriddedNoDesign_Fail), request.ProjectUid, request));

            Assert.Equal(System.Net.HttpStatusCode.BadRequest, ex.Code);
            Assert.Equal(ContractExecutionStatesEnum.ValidationError, ex.GetResult.Code);
            Assert.Equal($"CutFill design {cutFillDesignUid} is not found.", ex.GetResult.Message);
        }
Example #23
0
        public async Task CSVExportRequest_Execute_UnableToWriteResultToS3()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var tempFileName = MockS3FileTransfer_UploadToBucket("InvalidFilename*@");
            var siteModel    = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var request      = new CSVExportRequest();
            var baseDate     = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 0, 0, 0), DateTimeKind.Utc);

            var cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][];

            SubGridUtilities.SubGridDimensionalIterator((x, y) =>
            {
                cellPasses[x, y] = new[] { new CellPass {
                                               Time = baseDate, Height = 1.0f
                                           } };
            });

            DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel,
                                                                          SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses);

            var mockTransferProxy = new Mock <ITransferProxy>();

            mockTransferProxy.Setup(t => t.UploadToBucket(It.IsAny <Stream>(), It.IsAny <string>(), It.IsAny <string>())).Callback(() => throw new IOException("S3 not available"));
            var mockTransferProxyFactory = new Mock <ITransferProxyFactory>();

            mockTransferProxyFactory.Setup(x => x.NewProxy(It.IsAny <TransferProxyType>())).Returns(mockTransferProxy.Object);

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton(mockTransferProxyFactory.Object))
            .Complete();

            var response = await request.ExecuteAsync(SimpleCSVExportRequestArgument(siteModel.ID));

            response.Should().NotBeNull();
            response.ResultStatus.Should().Be(RequestErrorStatus.ExportUnableToLoadFileToS3);

            CleanupMockedFile(tempFileName, siteModel.ID);
        }
Example #24
0
        public void AcquireIgniteTopologyProjections_FailWithNullComputeProjection()
        {
            var igniteMock = new IgniteMock();

            // Nobble the ICompute setup to mimic a null compute projection
            igniteMock.mockClusterGroup.Setup(x => x.GetCompute()).Returns((ICompute)null);

            DIBuilder.Continue()
            .Add(TRexGridFactory.AddGridFactoriesToDI)

            // Override the main Ignite grid factory method DI'ed from TRexGridFactory.AddGridFactoriesToDI()
            .Add(x => x.AddSingleton <Func <string, IgniteConfiguration, IIgnite> >(factory => (gridName, cfg) => igniteMock.mockIgnite.Object))
            .Complete();

            var GridName = TRexGrids.GridName(StorageMutability.Immutable);
            var Role     = "TestRole";

            Action act = () => new BaseIgniteClass(GridName, Role);

            act.Should().Throw <TRexException>().WithMessage($"Compute projection is null in AcquireIgniteTopologyProjections on grid {GridName}");
        }
Example #25
0
        /// <summary>Initializes a new instance of the <see cref="BitcodeModule"/> class with a root <see cref="DICompileUnit"/> to contain debugging information</summary>
        /// <param name="context">Context for the module</param>
        /// <param name="moduleId">Module name</param>
        /// <param name="language">Language to store in the debugging information</param>
        /// <param name="srcFilePath">path of source file to set for the compilation unit</param>
        /// <param name="producer">Name of the application producing this module</param>
        /// <param name="optimized">Flag to indicate if the module is optimized</param>
        /// <param name="compilationFlags">Additional flags</param>
        /// <param name="runtimeVersion">Runtime version if any (use 0 if the runtime version has no meaning)</param>
        public BitcodeModule(Context context
                             , string moduleId
                             , SourceLanguage language
                             , string srcFilePath
                             , string producer
                             , bool optimized          = false
                             , string compilationFlags = ""
                             , uint runtimeVersion     = 0
                             )
            : this(context, moduleId)
        {
            DICompileUnit = DIBuilder.CreateCompileUnit(language
                                                        , srcFilePath
                                                        , producer
                                                        , optimized
                                                        , compilationFlags
                                                        , runtimeVersion
                                                        );

            SourceFileName = Path.GetFileName(srcFilePath);
        }
Example #26
0
        public void ValidateReportData_AlignmentIncludingCutFill_Success(Guid projectUid, Guid cutFillDesignUid, double?cutFillDesignOffset, Guid alignmentDesignUid)
        {
            var mockSiteModel  = new Mock <ISiteModel>();
            var mockSiteModels = new Mock <ISiteModels>();

            mockSiteModels.Setup(x => x.GetSiteModel(It.IsAny <Guid>(), It.IsAny <bool>())).Returns(mockSiteModel.Object);

            var mockDesign        = new Mock <IDesign>();
            var mockDesigns       = new Mock <IDesigns>();
            var mockDesignManager = new Mock <IDesignManager>();

            mockDesignManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockDesigns.Object);
            mockDesigns.Setup(x => x.Locate(It.IsAny <Guid>())).Returns(mockDesign.Object);

            var mockAlignment        = new Mock <IAlignment>();
            var mockAlignments       = new Mock <IAlignments>();
            var mockAlignmentManager = new Mock <IAlignmentManager>();

            mockAlignmentManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockAlignments.Object);
            mockAlignments.Setup(x => x.Locate(It.IsAny <Guid>())).Returns(mockAlignment.Object);

            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <ISiteModels>(mockSiteModels.Object))
            .Add(x => x.AddSingleton <IDesignManager>(mockDesignManager.Object))
            .Add(x => x.AddSingleton <IAlignmentManager>(mockAlignmentManager.Object))
            .Add(x => x.AddTransient <IReportDataValidationUtility, ReportDataValidationUtility>())
            .Complete();

            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                projectUid, null,
                true, true, true, true, true, true,
                cutFillDesignUid, cutFillDesignOffset, alignmentDesignUid,
                2.0, 100, 200, new[] { -1.0, 0, 1.3 }, null, null);

            var isOk = DIContext.Obtain <IReportDataValidationUtility>().ValidateData(nameof(ValidateReportData_AlignmentIncludingCutFill_Success), request.ProjectUid, request);

            Assert.True(isOk);
        }
Example #27
0
        private static void DependencyInjection()
        {
            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <IConfigurationStore, GenericConfiguration>())
            .Build()
            .Add(x => x.AddSingleton <ITransferProxyFactory>(factory => new TransferProxyFactory(factory.GetRequiredService <IConfigurationStore>(), factory.GetRequiredService <ILoggerFactory>())))
            .Add(x => x.AddSingleton <ICoreXWrapper, CoreXWrapper>())
            .Add(VSS.TRex.IO.DIUtilities.AddPoolCachesToDI)
            .Add(VSS.TRex.Cells.DIUtilities.AddPoolCachesToDI)
            .Add(TRexGridFactory.AddGridFactoriesToDI)
            .Add(VSS.TRex.Storage.Utilities.DIUtilities.AddProxyCacheFactoriesToDI)
            .Build()
            .Add(x => x.AddTransient <IFilterSet>(factory => new FilterSet()))
            .Add(x => x.AddSingleton <ISiteModels>(new SiteModels.SiteModels(StorageMutability.Immutable)))
            .Add(x => x.AddSingleton <ISiteModelFactory>(new SiteModelFactory()))
            .Add(ExistenceMaps.ExistenceMaps.AddExistenceMapFactoriesToDI)
            .Add(x => x.AddSingleton <IProductionEventsFactory>(new ProductionEventsFactory()))
            .Build()
            .Add(x => x.AddSingleton(new CalculateDesignElevationsServer()))
            .Add(X => X.AddTransient <IDesigns>(factory => new Designs.Storage.Designs()))
            .Add(x => x.AddSingleton <IDesignFiles>(new DesignFiles()))
            .Add(x => x.AddSingleton <IDesignManager>(factory => new DesignManager(StorageMutability.Immutable)))
            .Add(x => x.AddTransient <ISurveyedSurfaces>(factory => new SurveyedSurfaces.SurveyedSurfaces()))
            .Add(x => x.AddSingleton <ISurveyedSurfaceManager>(factory => new SurveyedSurfaceManager(StorageMutability.Immutable)))
            .Add(x => x.AddTransient <IAlignments>(factory => new Alignments.Alignments()))
            .Add(x => x.AddSingleton <IAlignmentManager>(factory => new AlignmentManager(StorageMutability.Immutable)))
            //.Add(x => x.AddSingleton<IDesignChangedEventListener>(new DesignChangedEventListener(TRexGrids.ImmutableGridName())))
            .Add(x => x.AddSingleton <ITRexHeartBeatLogger>(new TRexHeartBeatLogger()))
            .Add(x => x.AddSingleton <IOptimisedTTMProfilerFactory>(new OptimisedTTMProfilerFactory()))
            .Add(x => x.AddSingleton <IDesignClassFactory>(new DesignClassFactory()))
            .Add(x => x.AddSingleton <IClientLeafSubGridFactory>(ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory()))

            // Register the listener for site model attribute change notifications
            //.Add(x => x.AddSingleton<ISiteModelAttributesChangedEventListener>(new SiteModelAttributesChangedEventListener(TRexGrids.ImmutableGridName())))

            .Complete();
        }
Example #28
0
        public override void SetupFixture()
        {
            base.SetupFixture();

            var mockSiteModelMetadataManager = new Mock <ISiteModelMetadataManager>();
            var mockSiteModelAttributesChangedEventSender = new Mock <ISiteModelAttributesChangedEventSender>();

            DIBuilder
            .Continue()

            .Add(x => AddProxyCacheFactoriesToDI())

            .Add(x => x.AddSingleton <ISubGridSpatialAffinityKeyFactory>(new SubGridSpatialAffinityKeyFactory()))

            .Add(x => x.AddSingleton <ISiteModels>(new TRex.SiteModels.SiteModels(StorageMutability.Immutable)))
            .Add(x => x.AddSingleton <ISiteModelFactory>(new SiteModelFactory()))
            .Add(x => x.AddSingleton <ISiteModelMetadataManager>(factory => new SiteModelMetadataManager(StorageMutability.Mutable)))

            .Add(x => x.AddTransient <ISurveyedSurfaces>(factory => new TRex.SurveyedSurfaces.SurveyedSurfaces()))

            .Add(x => x.AddSingleton <IProductionEventsFactory>(new ProductionEventsFactory()))
            .Add(x => x.AddSingleton <IMutabilityConverter>(new MutabilityConverter()))
            .Add(x => x.AddSingleton <ISiteModelMetadataManager>(mockSiteModelMetadataManager.Object))

            .Add(x => x.AddTransient <IDesigns>(factory => new TRex.Designs.Storage.Designs()))
            .Add(x => x.AddSingleton <IDesignManager>(factory => new DesignManager(StorageMutability.Mutable)))
            .Add(x => x.AddSingleton <ISurveyedSurfaceManager>(factory => new SurveyedSurfaceManager(StorageMutability.Mutable)))
            .Add(x => x.AddTransient <IAlignments>(factory => new TRex.Alignments.Alignments()))
            .Add(x => x.AddSingleton <IAlignmentManager>(factory => new AlignmentManager(StorageMutability.Mutable)))

            .Add(x => x.AddSingleton <ISiteModelAttributesChangedEventSender>(mockSiteModelAttributesChangedEventSender.Object))

            // Register the hook used to capture cell pass mutation events while processing TAG files.
            .Add(x => x.AddSingleton <ICell_NonStatic_MutationHook>(new Cell_NonStatic_MutationHook()))

            .Complete();

            MockACSDependencies(); // default mocking behaviour for ACS tagfiles
        }
Example #29
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddMvc();
            services.AddDbContext <DataContext>(options =>
                                                options.UseSqlServer(
                                                    Configuration.GetConnectionString("DefaultConnection"),
                                                    b => b.MigrationsAssembly("DbRepository")));

            services.AddIdentity <User, IdentityRole>()
            .AddEntityFrameworkStores <DataContext>();

            var mapperConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            services.AddSingleton(mapperConfig.CreateMapper());

            DIBuilder.ConfigureServices(services);
            DIBuilder.ConfigureRepositories(services);
        }
Example #30
0
        public void AcquireIgniteTopologyProjections_FailWithNullIgnite()
        {
            // Ensure any injected IIgnite anf ITRexGridFactory are removed

            DIBuilder.Continue()
            .RemoveSingle <IIgnite>()
            .RemoveSingle <ITRexGridFactory>()
            .Complete();

            var gridName = TRexGrids.GridName(StorageMutability.Immutable);
            var role     = "TestRole";

            Action act = () => _ = new BaseIgniteClass(gridName, role);

            if (DIContext.DefaultIsRequired)
            {
                act.Should().Throw <InvalidOperationException>().WithMessage("No service for type 'VSS.TRex.GridFabric.Grids.ITRexGridFactory' has been registered.");
            }
            else
            {
                act.Should().Throw <TRexException>().WithMessage("Ignite reference is null in AcquireIgniteTopologyProjections");
            }
        }