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 } }
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 } }
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}"); }