Esempio n. 1
0
        /// <summary>
        /// Add the factories for the storage proxy caches, both standard and transacted, for spatial and non spatial caches in TRex
        /// </summary>
        private static void AddDIEntries()
        {
            DIBuilder.Continue()

            //***********************************************
            // Injected factories for non-transacted proxies
            // **********************************************

            // Add the singleton reference to the non-transacted site model change map cache
            .Add(x => x.AddSingleton <Func <IStorageProxyCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem> > >(
                     () => new StorageProxyCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem>(DIContext.Obtain <ITRexGridFactory>()
                                                                                                                   .Grid(StorageMutability.Immutable)?
                                                                                                                   .GetCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem>(TRexCaches.SiteModelChangeBufferQueueCacheName())))
                 )

            //******************************************
            // Injected factories for transacted proxies
            // *****************************************

            // Add the singleton reference to the transacted site model change map cache
            .Add(x => x.AddSingleton <Func <IStorageProxyCacheTransacted <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem> > >(
                     () => new StorageProxyCacheTransacted <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem>(DIContext.Obtain <ITRexGridFactory>()
                                                                                                                             .Grid(StorageMutability.Immutable)?
                                                                                                                             .GetCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem>(TRexCaches.SiteModelChangeBufferQueueCacheName()), new SiteModelChangeBufferQueueKeyEqualityComparer())
                     ));
        }
Esempio n. 2
0
 private static void AddDIEntries()
 {
     DIBuilder.Continue()
     .Add(x => x.AddSingleton <IActivatePersistentGridServer, ActivatePersistentGridServer>())
     .Add(x => x.AddSingleton <Func <string, IgniteConfiguration, IIgnite> >(factory => (gridName, cfg) => Ignition.TryGetIgnite(gridName) ?? (cfg == null ? null : Ignition.Start(cfg))))
     .Add(x => x.AddSingleton <ITRexGridFactory, TRexGridFactory>());
 }
Esempio n. 3
0
        private (ISiteModel siteModelId, Guid alignmentId) ConstructSimpleArcNFFFileModel()
        {
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            var arc = new NFFLineworkArcEntity(0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, true, false)
            {
                StartStation = 0
            };

            var alignment = new NFFGuidableAlignmentEntity();

            alignment.Entities.Add(arc);

            var alignmentGuid = Guid.NewGuid();
            var testDesign    = new SVLAlignmentDesign(alignment);

            siteModel.Alignments.AddAlignmentDetails(alignmentGuid, new DesignDescriptor(alignmentGuid, "", ""), BoundingWorldExtent3D.Full());

            var mockDesignFiles = new Mock <IDesignFiles>();

            mockDesignFiles.Setup(x => x.Lock(It.IsAny <Guid>(), It.IsAny <ISiteModelBase>(), It.IsAny <double>(), out It.Ref <DesignLoadResult> .IsAny))
            .Returns(new GobbleDesignFilesLockReturns((Guid designUid, ISiteModelBase siteModel, double cellSize, out DesignLoadResult result) =>
            {
                result = DesignLoadResult.Success;
                return(testDesign);
            }));

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

            return(siteModel, alignmentGuid);
        }
Esempio n. 4
0
 private void InjectCoordinateService()
 {
     DIBuilder
     .Continue()
     .Add(x => x.AddSingleton <ICoreXWrapper, CoreXWrapper>())
     .Complete();
 }
Esempio n. 5
0
        private void AddChangeMapQueueCacheToDI()
        {
            var transactedProxy = new StorageProxyCacheTransacted_TestHarness <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem>
                                      (DIContext.Obtain <ITRexGridFactory>().Grid(StorageMutability.Immutable)?.GetCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem>(TRexCaches.SiteModelChangeBufferQueueCacheName()), new SiteModelChangeBufferQueueKeyEqualityComparer());

            var nonTransactedProxy = new StorageProxyCacheTransacted_TestHarness <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem>
                                         (DIContext.Obtain <ITRexGridFactory>().Grid(StorageMutability.Immutable)?.GetCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem>(TRexCaches.SiteModelChangeBufferQueueCacheName()), new SiteModelChangeBufferQueueKeyEqualityComparer());

            DIBuilder
            .Continue()

            // Add the factories for the storage proxy caches, both standard and transacted, for spatial and non spatial caches in TRex

            ////////////////////////////////////////////////////
            // Injected standard storage proxy cache
            ////////////////////////////////////////////////////

            // Add the singleton reference to the non-transacted site model change map cache
            .Add(x => x.AddSingleton <Func <IStorageProxyCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem> > >(() => nonTransactedProxy))

            /////////////////////////////////////////////////////
            // Injected transacted storage proxy cache factories
            /////////////////////////////////////////////////////

            // Add the singleton reference to the transacted site model change map cache
            .Add(x => x.AddSingleton <Func <IStorageProxyCacheTransacted <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem> > >(() => transactedProxy))

            .Build()
            .Add(x => x.AddSingleton <ISiteModelChangeMapDeltaNotifier>(new SiteModelChangeMapDeltaNotifier()))

            .Build();
        }
Esempio n. 6
0
        public void Persist_UnSuccessful_NoAWS()
        {
            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 originalConfiguration = DIContext.Obtain <IConfigurationStore>();
            var moqConfiguration      = DIContext.Obtain <Mock <IConfigurationStore> >();

            moqConfiguration.Setup(c => c.GetValueString("AWS_TEMPORARY_BUCKET_NAME")).Returns((string)null);
            moqConfiguration.Setup(c => c.GetValueString("AWS_TEMPORARY_BUCKET_NAME", It.IsAny <string>())).Returns((string)null);

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

            Action act = () => new CSVExportFileWriter(requestArgument);

            act.Should().Throw <ServiceException>();

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton <IConfigurationStore>(originalConfiguration))
            .Complete();
        }
Esempio n. 7
0
        private void SetupDIDeviceGateay(bool enableDeviceGateway = true)
        {
            var moqCustomHeaders = new HeaderDictionary()
            {
            };

            var moqTPaaSApplicationAuthentication = new Mock <ITPaaSApplicationAuthentication>();
            var moqCwsDeviceGateway = new Mock <ICwsDeviceGatewayClient>();

            moqTPaaSApplicationAuthentication.Setup(mk => mk.CustomHeaders()).Returns(moqCustomHeaders);
            moqCwsDeviceGateway.Setup(mk => mk.CreateDeviceLKS(It.IsAny <string>(), It.IsAny <DeviceLKSModel>(), It.IsAny <HeaderDictionary>()));

            //Moq doesn't support extension methods in IConfiguration/Root.
            var moqConfiguration = DIContext.Obtain <Mock <IConfigurationStore> >();

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

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton <ITPaaSApplicationAuthentication>(moqTPaaSApplicationAuthentication.Object))
            .Add(x => x.AddSingleton <ICwsDeviceGatewayClient>(moqCwsDeviceGateway.Object))
            .Add(x => x.AddSingleton <IConfigurationStore>(moqConfiguration.Object))
            .Build();
        }
Esempio n. 8
0
 public new void SetupFixture()
 {
     DIBuilder
     .Continue()
     .Add(x => x.AddSingleton <Func <DataSmootherOperation, IDataSmoother> >(provider => SurfaceExportSmootherFactoryMethod))
     .Complete();
 }
Esempio n. 9
0
        public void CreateHeaders_VedaFinalPass()
        {
            var projectUid = Guid.NewGuid();

            var csvExportUserPreference = new CSVExportUserPreferences();
            var requestArgument         = new CSVExportRequestArgument
                                          (
                projectUid, new FilterSet(new CombinedFilter()), "the filename",
                CoordType.Northeast, OutputTypes.VedaFinalPass,
                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, true);

            csvExportFileWriter.PersistResult(dataRows);

            var localExportPath = FilePathHelper.GetTempFolderForExport(requestArgument.ProjectID, "");
            var uniqueFileName  = requestArgument.FileName + "__" + requestArgument.TRexNodeID;

            var firstFile = Path.Combine(localExportPath, uniqueFileName, requestArgument.FileName + CSV_extension);

            if (!FileSystem.Exists(firstFile))
            {
                Assert.True(true, $"firstFile: {firstFile} should exist");
            }

            string header;

            using (var fs = new StreamReader(firstFile)) header = fs.ReadLine();
            header.Should().NotBeNullOrEmpty();
            header.Should().Be("Time,CellN_m,CellE_m,Elevation_m,PassCount,LastRadioLtncy,DesignName,Machine,Speed_km/h,LastGPSMode,GPSAccTol_m,TargPassCount,TotalPasses,Lift,LastCMV,TargCMV,LastMDP,TargMDP,LastRMV,LastFreq_Hz,LastAmp_mm,TargThickness_m,MachineGear,VibeState,LastTemp,_c");

            var projectDir = localExportPath.Remove(localExportPath.Length - 7);

            if (Directory.Exists(projectDir))
            {
                Directory.Delete(projectDir, true);
            }
        }
Esempio n. 10
0
 /// <summary>
 ///  The real deal test setup for ACS conversion
 /// </summary>
 private void InjectACSDependencies()
 {
     DIBuilder
     .Continue()
     .Add(x => x.AddSingleton <IACSTranslator, ACSTranslator>())
     .Add(x => x.AddSingleton <ICoreXWrapper, CoreXWrapper>())
     .Complete();
 }
Esempio n. 11
0
        public TRexSpatialMemoryCacheContextTests()
        {
            // Set the cache removal timeout to zero for unit test purposes
            var configurationMock = DIContext.Obtain <Mock <IConfigurationStore> >();

            configurationMock.Setup(c => c.GetValueInt("SPATIAL_MEMORY_CACHE_INVALIDATED_CACHE_CONTEXT_REMOVAL_WAIT_TIME_SECONDS", It.IsAny <int>())).Returns(0);
            DIBuilder.Continue().Add(x => x.AddSingleton <IConfigurationStore>(DIContext.Obtain <Mock <IConfigurationStore> >().Object)).Complete();
        }
Esempio n. 12
0
        private void SetupDITfa(int vlpdSubGridSegmentPassCountLimit = Consts.VLPDSUBGRID_SEGMENTPASSCOUNTLIMIT)
        {
            var moqConfiguration = DIContext.Obtain <Mock <IConfigurationStore> >();

            moqConfiguration.Setup(x => x.GetValueInt("VLPDSUBGRID_SEGMENTPASSCOUNTLIMIT", It.IsAny <int>())).Returns(vlpdSubGridSegmentPassCountLimit);

            DIBuilder.Continue().Add(x => x.AddSingleton(moqConfiguration.Object)).Complete();
        }
Esempio n. 13
0
        public ExtractDXFBoundariesExecutorTests()
        {
            // Mock the coordinate conversion service
            var mockCoordinateService = new Mock <ICoreXWrapper>();

            mockCoordinateService.Setup(x => x.NEEToLLH(It.IsAny <string>(), It.IsAny <CoreXModels.XYZ[]>(), It.IsAny <CoreX.Types.ReturnAs>())).Returns((string csib, CoreXModels.XYZ[] coordinates, CoreX.Types.ReturnAs returnAs) => coordinates);

            DIBuilder.Continue().Add(x => x.AddSingleton(mockCoordinateService.Object)).Complete();
        }
Esempio n. 14
0
        private void SetupTest()
        {
            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile-QMesh.tag"),
            };

            siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var boundary = new List <Fence>()
            {
                new Fence()
            };

            boundary[0].Points.Add(new FencePoint(2700.20170260547, 1225.08445683629, 0.0));
            boundary[0].Points.Add(new FencePoint(2700.16517351542, 1224.38744027628, 0.0));
            boundary[0].Points.Add(new FencePoint(2700.10136538994, 1223.16990871245, 0.0));
            boundary[0].Points.Add(new FencePoint(2889.7599542129, 1178.36648123432, 0.0));

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

            // mock tile boundary within model extents
            //WS
            neeCoords[0].X = Math.Round(2847.26, DECIMALS);
            neeCoords[0].Y = Math.Round(1219.93, DECIMALS);
            //EN
            neeCoords[1].X = Math.Round(2879.11, DECIMALS);
            neeCoords[1].Y = Math.Round(1276.37, DECIMALS);
            //WN
            neeCoords[2].X = Math.Round(2847.26, DECIMALS);
            neeCoords[2].Y = Math.Round(1276.37, DECIMALS);
            // ES
            neeCoords[3].X = Math.Round(2879.11, DECIMALS);
            neeCoords[3].Y = Math.Round(1219.93, DECIMALS);

            var llhCoords = new XYZ[2500];

            for (int i = 0; i < 2500; i++)
            {
                llhCoords[i].X = Math.Round(2847.26 + i, DECIMALS);
                llhCoords[i].Y = Math.Round(1219.93 + i, DECIMALS);
            }

            var expectedCoordinateConversionResult  = neeCoords.ToCoreX_XYZ();
            var expectedCoordinateConversionResult2 = llhCoords.ToCoreX_XYZ();

            // LL to NEE
            var convertCoordinatesMock = new Mock <ICoreXWrapper>();

            convertCoordinatesMock.Setup(x => x.LLHToNEE(It.IsAny <string>(), It.IsAny <CoreXModels.XYZ[]>(), CoreX.Types.InputAs.Radians)).Returns(expectedCoordinateConversionResult);
            convertCoordinatesMock.Setup(x => x.NEEToLLH(It.IsAny <string>(), It.IsAny <CoreXModels.XYZ[]>(), CoreX.Types.ReturnAs.Radians)).Returns(expectedCoordinateConversionResult2);
            DIBuilder.Continue().Add(x => x.AddSingleton(convertCoordinatesMock.Object)).Complete();

            filter = new FilterSet(new CombinedFilter());
        }
Esempio n. 15
0
        public void AddProxyCacheFactoriesToDI()
        {
            _tagFileBufferQueue = null;

            DIBuilder
            .Continue()

            // Add the factories for the storage proxy caches, both standard and transacted, for spatial and non spatial caches in TRex

            /////////////////////////////////////////////////////
            // Injected standard storage proxy cache factories
            /////////////////////////////////////////////////////

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer())))

            /////////////////////////////////////////////////////
            // Injected transacted storage proxy cache factories
            /////////////////////////////////////////////////////

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted_TestHarness <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <ITAGFileBufferQueue> >(factory => () =>
            {
                _tagFileBufferQueue ??= new TAGFileBufferQueue();
                return(_tagFileBufferQueue);
            }))

            .Build();

            // Set up a singleton storage proxy for mutable and immutable contexts for tests when there is no Ignite mock available
            var mutableStorageProxy   = new StorageProxy_Ignite_Transactional(StorageMutability.Mutable);
            var immutableStorageProxy = new StorageProxy_Ignite_Transactional(StorageMutability.Immutable);

            DIBuilder
            .Continue()

            // Add the factory to create a single storage proxy instance.
            .Add(x => x.AddSingleton <Func <StorageMutability, IStorageProxy> >(factory => mutability => mutability == StorageMutability.Mutable ? mutableStorageProxy : immutableStorageProxy))
            .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()))
            .Build();
        }
Esempio n. 16
0
 private static void AddDIEntries(IServiceCollection services)
 {
     DIBuilder.Continue(services)
     .Add(x => x.AddSingleton(new RecyclableMemoryStreamManager
     {
         // Allow up to 256Mb worth of freed small blocks used by the recyclable streams for later reuse
         // Note: The default value for this setting is zero which means every block allocated to a
         // recyclable stream is freed when the stream is disposed.
         MaximumFreeSmallPoolBytes = 256 * 1024 * 1024
     }));
 }
Esempio n. 17
0
        public AlignmentDesignGeometryRequestTests(DITAGFileAndSubGridRequestsWithIgniteFixture fixture)
        {
            fixture.ClearDynamicFixtureContent();
            fixture.SetupFixture();

            // Fresh the DesignFiles DI for each test as some tests mock it specially
            DIBuilder.
            Continue()
            .Add(x => x.AddSingleton <IDesignFiles>(new DesignFiles()))
            .Complete();
        }
Esempio n. 18
0
        private void MockACSDependencies()
        {
            var mockACSTranslator = new Mock <IACSTranslator>();

            mockACSTranslator
            .Setup(x => x.TranslatePositions(It.IsAny <Guid?>(), It.IsAny <List <UTMCoordPointPair> >()))
            .Returns((Guid? x, List <UTMCoordPointPair> y) => y);

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton <IACSTranslator>(mockACSTranslator.Object))
            .Complete();
        }
Esempio n. 19
0
        public SiteModelRebuilderTests(DITAGFileAndSubGridRequestsWithIgniteFixture fixture)
        {
            fixture.ClearDynamicFixtureContent();
            fixture.ResetDynamicMockedIgniteContent();

            // Modify the SiteModels instance to be mutable, rather than immutable to mimic the mutable context
            // project deletion operates in
            DIBuilder
            .Continue()
            .RemoveSingle <ISiteModels>()
            .Add(x => x.AddSingleton <ISiteModels>(new TRex.SiteModels.SiteModels(StorageMutability.Mutable)))
            .Complete();
        }
Esempio n. 20
0
        public DILoggingAndStorageProxyFixture()
        {
            var moqStorageProxy = new Mock <IStorageProxy>();

            var moqStorageProxyFactory = new Mock <IStorageProxyFactory>();

            moqStorageProxyFactory.Setup(mk => mk.Storage(StorageMutability.Immutable)).Returns(moqStorageProxy.Object);
            moqStorageProxyFactory.Setup(mk => mk.Storage(StorageMutability.Mutable)).Returns(moqStorageProxy.Object);

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton <IStorageProxyFactory>(moqStorageProxyFactory.Object))
            .Complete();
        }
Esempio n. 21
0
        public DeleteSiteModelRequestTests(DITAGFileAndSubGridRequestsWithIgniteFixture fixture)
        {
            // This resets all modified content in the Ignite mocks between tests
            fixture.ClearDynamicFixtureContent();
            fixture.SetupFixture();

            // Modify the SiteModels instance to be mutable, rather than immutable to mimic the mutable context
            // project deletion operates in
            DIBuilder
            .Continue()
            .RemoveSingle <ISiteModels>()
            .Add(x => x.AddSingleton <ISiteModels>(new TRex.SiteModels.SiteModels(StorageMutability.Mutable)))
            .Complete();
        }
Esempio n. 22
0
        public void Test_MutabilityConverterTests_ConvertEventListTest()
        {
            DIBuilder
            .Continue()
            .Add(VSS.TRex.Storage.Utilities.DIUtilities.AddProxyCacheFactoriesToDI)
            .Build();

            var storageProxy = new StorageProxy_Ignite_Transactional(StorageMutability.Mutable);

            storageProxy.SetImmutableStorageProxy(new StorageProxy_Ignite_Transactional(StorageMutability.Immutable));

            var moqSiteModels = new Mock <ISiteModels>();

            moqSiteModels.Setup(mk => mk.PrimaryMutableStorageProxy).Returns(storageProxy);

            DIBuilder
            .Continue()
            .Add(x => x.AddSingleton <IProductionEventsFactory>(new ProductionEventsFactory()))
            .Add(x => x.AddSingleton <ISiteModels>(moqSiteModels.Object))
            .Complete();

            var siteModel = new SiteModel(Guid.Empty, StorageMutability.Immutable, true);
            var events    = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);

            DateTime ReferenceTime = DateTime.UtcNow;

            events.MachineDesignNameIDStateEvents.PutValueAtDate(ReferenceTime.AddMinutes(-60), 0);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(ReferenceTime.AddMinutes(-30), 1);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(ReferenceTime.AddMinutes(-29), 1);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(ReferenceTime.AddMinutes(-29), 2);
            events.MachineDesignNameIDStateEvents.PutValueAtDate(ReferenceTime.AddMinutes(-29), 3);
            Assert.True(3 == events.MachineDesignNameIDStateEvents.Count(), $"List contains {events.MachineDesignNameIDStateEvents.Count()} MachineDesignName events, instead of 3");

            var mutableStream   = events.MachineDesignNameIDStateEvents.GetMutableStream();
            var targetEventList = Deserialize(mutableStream);

            Assert.Equal(3, targetEventList.Count());

            var mutabilityConverter = new MutabilityConverter();

            mutabilityConverter.ConvertToImmutable(FileSystemStreamType.Events, null, events.MachineDesignNameIDStateEvents, out MemoryStream immutableStream);

            targetEventList = Deserialize(immutableStream);
            Assert.Equal(2, targetEventList.Count());

            mutabilityConverter.ConvertToImmutable(FileSystemStreamType.Events, mutableStream, null, out immutableStream);
            targetEventList = Deserialize(immutableStream);
            Assert.Equal(2, targetEventList.Count());
        }
Esempio n. 23
0
        /// <summary>
        /// Add the factories for the storage proxy caches, both standard and transacted, for spatial and non spatial caches in TRex
        /// </summary>
        private static void AddDIEntries()
        {
            DIBuilder.Continue()
            .Add(x => x.AddSingleton <IStorageProxyFactory>(new StorageProxyFactory()))

            //***********************************************
            // Injected factories for non-transacted proxies
            // **********************************************

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)))))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)))))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) =>
            {
                // SiteModel change maps are only maintained on the immutable grid
                if (mutability != StorageMutability.Immutable)
                {
                    return(null);
                }

                return(new StorageProxyCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType))));
            }))

            //***********************************************
            // Injected factories for transacted proxies
            // **********************************************

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISubGridSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.SpatialCacheName(mutability, streamType)), new SubGridSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) => new StorageProxyCacheTransacted <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <INonSpatialAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new NonSpatialAffinityKeyEqualityComparer())))

            .Add(x => x.AddSingleton <Func <IIgnite, StorageMutability, FileSystemStreamType, IStorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper> > >
                     (factory => (ignite, mutability, streamType) =>
            {
                // SiteModel change maps are only maintained on the immutable grid
                if (mutability != StorageMutability.Immutable)
                {
                    return(null);
                }

                return(new StorageProxyCacheTransacted <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(ignite?.GetCache <ISiteModelMachineAffinityKey, ISerialisedByteArrayWrapper>(TRexCaches.NonSpatialCacheName(mutability, streamType)), new SiteModelMachineAffinityKeyEqualityComparer()));
            }));
        }
Esempio n. 24
0
        public static void SetMaxExportRowsConfig(int rowCount)
        {
            // this Fixture sets to Consts.DEFAULT_MAX_EXPORT_ROWS. Some tests need it to be something different.
            var moqConfiguration = DIContext.Obtain <Mock <IConfigurationStore> >();

            moqConfiguration.Setup(x => x.GetValueInt("MAX_EXPORT_ROWS")).Returns(rowCount);
            moqConfiguration.Setup(x => x.GetValueInt("MAX_EXPORT_ROWS", It.IsAny <int>())).Returns(rowCount);

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

            var configuration = DIContext.Obtain <IConfigurationStore>();

            configuration.GetValueInt("MAX_EXPORT_ROWS").Should().Be(rowCount);
            configuration.GetValueInt("MAX_EXPORT_ROWS", 1).Should().Be(rowCount);
        }
Esempio n. 25
0
        public void AcquireIgniteTopologyProjections_Success()
        {
            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();

            var ignite = new BaseIgniteClass(TRexGrids.GridName(StorageMutability.Immutable), "TestRole");

            ignite.AcquireIgniteTopologyProjections();
        }
Esempio n. 26
0
        public async void CallsRebuildManager_Async()
        {
            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);
            await executor.ProcessAsync(new ProjectRebuildRequest(Guid.NewGuid(), TransferProxyType.TAGFiles, false));

            mockManager.Verify(x => x.Rebuild(It.IsAny <Guid>(), It.IsAny <bool>(), It.IsAny <TransferProxyType>()), Times.Once);
        }
Esempio n. 27
0
        public override void SetupFixture()
        {
            base.SetupFixture();

            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();
        }
Esempio n. 28
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();
        }
Esempio n. 29
0
        private void AddSimpleNEEToLLHConversionMock()
        {
            var result = new CoreXModels.XYZ[2]
            {
                new CoreXModels.XYZ(0, 0, 1),
                new CoreXModels.XYZ(1, 1, 0)
            };

            var csMock = new Mock <ICoreXWrapper>();

            csMock.Setup(x => x.NEEToLLH(It.IsAny <string>(), It.IsAny <CoreXModels.XYZ[]>(), It.IsAny <CoreX.Types.ReturnAs>()))
            .Returns(result);

            DIBuilder.Continue()
            .Add(x => x.AddSingleton(csMock.Object))
            .Complete();
        }
Esempio n. 30
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);
        }