Ejemplo n.º 1
0
        public async void Boundaries_OverLimit(string fileName, DxfUnitsType units, int firstBoundaryVertexCount)
        {
            const int LIMIT = 5;

            var request = new DXFBoundariesRequest("", ImportedFileType.SiteBoundary,
                                                   Convert.ToBase64String(File.ReadAllBytes(Path.Combine("TestData", fileName))), units, LIMIT, false);
            var executor = new ExtractDXFBoundariesExecutor(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>());

            executor.Should().NotBeNull();

            var result = await executor.ProcessAsync(request);

            result.Should().NotBeNull();
            result.Code.Should().Be(ContractExecutionStatesEnum.ExecutedSuccessfully);
            result.Message.Should().Be("Success");

            if (result is DXFBoundaryResult boundary)
            {
                boundary.Boundaries.Count.Should().Be(LIMIT);
                boundary.Boundaries[0].Fence.Count.Should().Be(firstBoundaryVertexCount);
            }
            else
            {
                false.Should().BeTrue(); // fail the test
            }
        }
Ejemplo n.º 2
0
        private async void TestAFile(string fileName, DxfUnitsType units, int expectedBoundaryCount, int firstBoundaryVertexCount, string expectedName, DXFLineWorkBoundaryType expectedType, bool allowUnclosedBoundaries)
        {
            var request = new DXFBoundariesRequest("", ImportedFileType.SiteBoundary,
                                                   Convert.ToBase64String(File.ReadAllBytes(Path.Combine("TestData", fileName))),
                                                   units, 10, allowUnclosedBoundaries);
            var executor = new ExtractDXFBoundariesExecutor(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>());

            executor.Should().NotBeNull();

            var result = await executor.ProcessAsync(request);

            result.Should().NotBeNull();
            result.Code.Should().Be(ContractExecutionStatesEnum.ExecutedSuccessfully);
            result.Message.Should().Be("Success");

            if (result is DXFBoundaryResult boundary)
            {
                boundary.Boundaries.Count.Should().Be(expectedBoundaryCount);

                if (expectedBoundaryCount > 0)
                {
                    boundary.Boundaries[0].Fence.Count.Should().Be(firstBoundaryVertexCount);
                    boundary.Boundaries[0].Name.Should().Be(expectedName);
                    boundary.Boundaries[0].Type.Should().Be(expectedType);
                }
            }
            else
            {
                false.Should().BeTrue(); // fail the test
            }
        }
Ejemplo n.º 3
0
        public async void Fail_With_InvalidFile()
        {
            var request = new DXFBoundariesRequest("", ImportedFileType.SiteBoundary,
                                                   Convert.ToBase64String(File.ReadAllBytes(Path.Combine("TestData", "TransferTestDesign.ttm"))), DxfUnitsType.Meters, 10, false);
            var executor = new ExtractDXFBoundariesExecutor(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>());

            executor.Should().NotBeNull();

            Func <Task> act = async() => await executor.ProcessAsync(request);

            act.Should().Throw <ServiceException>().WithMessage($"Error processing file: {DXFUtilitiesResult.UnknownFileFormat}");
        }
Ejemplo n.º 4
0
        public void Creation()
        {
            var executor = new ExtractDXFBoundariesExecutor(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>());

            executor.Should().NotBeNull();
        }