Skip to content

Latest commit

 

History

History
107 lines (75 loc) · 3.85 KB

Coding.md

File metadata and controls

107 lines (75 loc) · 3.85 KB

Coding RDMP

Contents

  1. Background
  2. Libraries
    1. Database Abstraction layer
    2. Type Determination
  3. Writing your first unit test
  4. Further Reading

Background

RDMP is a large codebase and can be quite intimidating at first glance. The good news is functionality is well separated and there is plenty of documentation on features.

Make sure you can build and run the unit tests (see README.md)

Libraries

Many of the complicated low level APIs have been refactored out of RDMP and moved to their own repositories. These are consumed by RDMP during the build process via Nuget packages.

Database Abstraction Layer

RDMP interacts with relational databases (Sql Server, Oracle, PostgresSQL and MySql). It runs SQL queries, creates tables and does general ETL. This functionality has been abstracted out into the FAnsiSql library

Type Determination

Often we need to load untyped data (e.g. CSV) into a new table. This requires picking DBMS appropriate types that will fit the content while still being useful for querying later on. This functionality is handled by the TypeGuesser library. You can read more about how RDMP handles untyped data in CSVHandling.md

Writing your first unit test

Often the easiest way to get into coding is to write simple unit tests. Lets create one.

Start by cloning the RDMP repository. Once it is on your computer create a new file in the Rdmp.Core.Tests project e.g. ./Rdmp.Core.Tests/MyTest.cs:

using NUnit.Framework;

namespace Rdmp.Core.Tests
{
    class MyTest
    {
        [Test]
        public void MyTestMethod()
        {
            TestContext.Out.WriteLine("Hello World");
            Assert.Fail("Goodbye cruel world");
        }
    }
}

Hello world test

Run your test from visual studio or or the command line with:

dotnet test --filter MyTestMethod

Change the class to inherit from UnitTests and use the WhenIHaveA<T> method to get an RDMP object e.g. a Catalogue:

using NUnit.Framework;
using Rdmp.Core.Curation.Data;
using Tests.Common;

namespace Rdmp.Core.Tests
{
    class MyTest : UnitTests
    {
        [Test]
        public void MyTestMethod()
        {
            var catalogue = WhenIHaveA<Catalogue>();

            catalogue.Name = "Hi there";
            Assert.AreEqual("Hi there",catalogue.Name);
        }
    }
}

Example unit test

If you want to interact with a database e.g. test an extraction scenario you will need to setup integration testing databases.

Further Reading

Each area of the RDMP codebase has its own documentation. These include:

RDMP has over 20 class diagrams which you can open if you have visual studio. These files end in the extension .cd

If you have not already done so it is also a good idea to familiarise yourself with the FAQ.

If there is an area of the codebase that is confusing or you think would benefit from more documentation, open an Issue and describe it!