Just a small personal reminder to avoid multiple appointments with Dr. Google.
Showing posts with label Autocad Map 3d. Show all posts
Showing posts with label Autocad Map 3d. Show all posts
Wednesday, July 30, 2014
Tuesday, November 26, 2013
Gallio : Automated Integration Tests Autocad
1. Introduction
Gallio is a very flexible, and extensible
testing framework usedto run tests against the code that depends on the AutoCAD
API.
2. Download
Get the lastest version of Gallio at http://www.gallio.org
3. Extract Gallio
Extract the downloaded .zip file to any
location on your computer.
Before you extract the ZIP file, be sure to
check its properties and click “Unblock” if that option is available.
4. Setup MSVS 2012 (Existing or new project)
Add References
·
acdbmgd.dll
(Autocad)
·
acmgd.dll
(Autocad)
·
Gallio.dll,
MbUnit.dll (The default Gallio test runner looks for tests written in your DLL
that use the MbUnit testing framework.)
Configuration
·
Make
sure you set your target framework correctly
·
External
References should be set to 'Copy Local'= false (otherwise netload assemblies
won't work)
5. Create Batch
Create a .bat file and add the following code
to it:
SET
GALLIO_RUNTIME_PATH=C:\Users\Mysth\Downloads\GallioBundle-3.4.14.0\bin\
"C:\Users\Mysth\Downloads\GallioBundle-3.4.14.0\bin\Gallio.Echo.exe"
gallio.dll /r:AutoCAD
pause
Place the batch alongside the assembly
containing the tests.
6. Reports
Gallio can
generate reports with the results of the tests run in either html format or xml
format.
Add the
following to the batch to auto generate reports :
SET
GALLIO_RUNTIME_PATH=C:\Data\GallioBundle-3.4.14.0\bin
"C:\Data\GallioBundle-3.4.14.0\bin\Gallio.Echo.exe"
BRail.InfraNet.IntegrationTests.Domain.dll /r:AutoCAD/rt:xml /rt:html
Pause
Example run on
BRail.InfraNet.Domain assembly
7. Example
Create a Test Class where our tests will be
written in.
publicclassTests
{
[Test]
publicvoidTestCircleEqual()
{
var
services = newActiveServices();
services.EntityService.CreateCircle(0, 0, 20);
var id =
services.DocumentService.GetLast();
var
circle = services.EntityService.GetEntity(id) asCircle;
if
(circle != null)
{
Assert.AreEqual(20,
circle.Radius);
}
}
publicvoidTestCircleNotEqual()
{
var services = newActiveServices();
services.EntityService.CreateCircle(0, 0, 10);
var id =
services.DocumentService.GetLast();
var circle =
services.EntityService.GetEntity(id) asCircle;
if (circle != null)
{
Assert.AreEqual(20, circle.Radius);
}
}
}
Build your project and run the previously
configured .bat file. Gallio should launch Autocad, load all the necessary
assemblies and execute all tests. Gallio will close Autocad once all tests are executed. You should see the following test result.
One test passedone should have failed.
8. Known Issues
System.NotSupportedException:
An
attempt was made to load an assembly
from
a network location which would have caused the assembly to be sandboxed in
previous
versions of the .NET Framework. This release of the .NET Framework
does
not enable CAS policy by default, so this load may be dangerous. If this
load
is not intended to sandbox the assembly, please enable the
loadFromRemoteSources
switch. See http://go.microsoft.com/fwlink/?LinkId=155569
for more information.
Labels:
.NET,
Autocad,
Autocad Map 3d,
Automated Tests,
C#,
Gallio,
Map 3d,
MbUnit,
Testing
Monday, November 5, 2012
BulkCopy SDF 2 SDF AutoCAD Map3D
In this article I show you how to copy data from an SDF to an empty SDF carrying the same schema definition. In a next post I'll show you how to do it in C# and I'll show you how to map to properties in a different schema setup.
Monday, April 23, 2012
Comparer Project Part 1
Introduction
I started
working as CAD-GIS engineer on 2nd of March, and ever since I haven't been
posting anything new.
Recent activity
As I try to
build a recap on what I have done so far I thought I’d share what’s been realized
so far. Although I won’t be sharing the whole project here, I’ll be posting
some portions and insights on how I dealt with the given assignment.
Let’s start
by explaining what I had to accomplish.
My first small project
Too save
you from a long story … In short …
I had to
compare the contents of 2 AutoDesk Autocad DWG drawings on a few layers. Two
technical drawers started on the same drawing and had to classify some objects
on those layers. Because both can classify them differently, I had to compare
the differences once they end their classification.
They had to
be able to see and localize the differences and fix them in an appropriate
manner afterwards.
That’s the
project in a nutshell J
Architecture
My goal was
to build a Data Access Layer that has the potential to be used in other
projects as well. I also integrated some classes I wrote 1-2 years ago to make
the application much more stable and flexible. I did the best I could to build
a Model-View-ViewModel environment.
Let’s start
by sharing a picture of the architecture I used within the project.
Database Assembly DAL
The Data Access Layer is only the start of what should become a wrapper around the Autocad Libraries. The wrapper allows you to decouple layers and gives you the possibility to Unit-Test your project with sample data without the necessity of having a Autodesk product at hand to test the decoupled layers.
Although this method seems tedious at first, it should result in a gain of speed when developing new applications.
Objective DAL
Basically you're building a library that gives you access to clean and tested code which reduces bugs and errors in future development.
At the moment, I am only working inside a Map environment, but if adjusted slightly, this setup should allow you to extend the framework to support programming towards other CAD Autodesk products build on AutoDesk AutoCad and expose their API.
Looking at
this picture, it is quite obvious that using other products, build on AutoDesk
Autocad's basic module, will end up using a AutoDesk Autocad Drawing as well.
Object oriented programming and libraries
Because we
program in an object oriented environment it's an ideal opportunity to exploit
this and build a reusable library. Although this is a first step to build
something flexible and reusable, the path towards a good library won't be
without it's pitfalls and setbacks.
What might be reusable and valid code for
your library in one project, might become unusable in certain particular
situations. I'll try to prevent that as much as possible but I still have a
long way to go to become a better object oriented programmer to exclude that
from happening completely. Using the correct methods and pattern to build
robust and flexible libraries will be a big challenge.
If you talk
about objected oriented design, libraries and flexible code, we can't exclude
the use of interfaces. That's why I'll be using those throughout this project
because they are very powerful and give you the possibility to program flexible
environments.
What's next?
In a next post I'll be explaining what I've done with the DAL and I'll create an example in C# demonstrating what the methods inside the classes do.
What's next?
In a next post I'll be explaining what I've done with the DAL and I'll create an example in C# demonstrating what the methods inside the classes do.
Subscribe to:
Posts (Atom)









