This .NET Core 3.1 console application provides:
- deserialization of ProductionResults.xml,
- serialization of car objects to XML file,
- converting XML file to CSV via XSLT,
- saving XML to database using ORM,
- unit tests.
- C#,
- .NET Core 3.1,
- XSLT,
- xUnit,
- EntityFramework Core,
- Microsoft SQL Server.
- Model Classes
- Other Classes
- Serialization
- Conversion to CSV using XSLT
- Conversion example
- Tested functionalities
- Entity Framework Core
Class responsible for transforming datatype. Consist of method converting XML to CSV.
Class responsible for XML serialization and deserialization.
Class responsible for interacting with user by displaying messages and getting user input.
Class responsible for connecting to database, configuring tables and relation keys.
Class responsible for saving data to database and error handling.
Class consisting of all unit tests along with IEnumerable collections that allow running same test with multiple dataset.
Class allowing to read CSV rows as arguments to unit tests.
Serialization and deserialization is done by System.Xml.Serialization library. Fields in classes are decorated with attributes identifying their position in XML file.
- Serialization is implemented as void method that takes list of cars and output file name as argument,
- Deserialization is implemented as method that takes path to file as argument and returns ProductionReport object.
List of cars is converted to CSV format with header in first line. Features of each car are ommited.
ProductionResults.xml
<ProductionReport Manufacturer="Opel" Date="2015-02-18T12:32:02.8036669+01:00">
<Factories>
<Factory Name="Monachium Fab">
<ProducedCars>
<Car VIN="O002ABC002">
<ProductionYear>2007</ProductionYear>
<Model>Vectra</Model>
<Features>
<Feature Code="RXE">Reflektory xenonowe</Feature>
<Feature Code="SZW">Sportowe zawieszenie</Feature>
<Feature Code="SZD">Szyberdach</Feature>
</Features>
</Car>
<Car VIN="O004ABC004">
<ProductionYear>2005</ProductionYear>
<Model>Astra</Model>
<Features>
<Feature Code="RXE">Reflektory xenonowe</Feature>
</Features>
</Car>
</ProducedCars>
</Factory>
</Factories>
</ProductionReport>
Cars.xml
<?xml version="1.0"?>
<Cars>
<Car VIN="O002ABC002">
<ProductionYear>2007</ProductionYear>
<Model>Vectra</Model>
<Features>
<Feature Code="RXE">Reflektory xenonowe</Feature>
<Feature Code="SZW">Sportowe zawieszenie</Feature>
<Feature Code="SZD">Szyberdach</Feature>
</Features>
</Car>
<Car VIN="O004ABC004">
<ProductionYear>2005</ProductionYear>
<Model>Astra</Model>
<Features>
<Feature Code="RXE">Reflektory xenonowe</Feature>
</Features>
</Car>
</Cars>
Cars.csv
VIN,Rok produkcji,Model
O002ABC002,2007,Vectra
O004ABC004,2005,Astra
- XML serialization,
- XML deserialization,
- XML to CSV conversion,
- implemented interface IEqutable,
- overridden method ToString().
Application is integrated with Microsoft SQL Server by Entity Framework Core 3.1. Constraints are set using Fluent API.