Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-alpha1'
Browse files Browse the repository at this point in the history
  • Loading branch information
belidzs committed May 25, 2019
2 parents 70b3123 + eef3f06 commit aa0c1d7
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 2 deletions.
4 changes: 2 additions & 2 deletions BankAccount/BankAccount.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package >
<metadata>
<id>$id$</id>
<version>$version$-alpha0</version>
<version>$version$-alpha1</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>belidzs</owners>
<licenseUrl>https://github.com/belidzs/MagyarNemzetiBank.BankAccount/blob/develop/LICENCE</licenseUrl>
<projectUrl>https://github.com/belidzs/MagyarNemzetiBank.BankAccount</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>First alpha release</releaseNotes>
<releaseNotes>Second alpha release</releaseNotes>
<copyright>$copyright$</copyright>
<tags>mnb bank banking bank-account bankaccount giro central-bank hungarian</tags>
</metadata>
Expand Down
33 changes: 33 additions & 0 deletions BankAccount/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MagyarNemzetiBank.Properties")]
[assembly: AssemblyDescription("This library written in pure C# checks the validity of Hungarian bank account numbers and determines which bank they belong to.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Balázs Keresztury")]
[assembly: AssemblyProduct("MagyarNemzetiBank.BankAccount")]
[assembly: AssemblyCopyright("Copyright (c) 2019 Balázs Keresztury")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("46844df6-193c-425b-b616-7e659dee4fb0")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
6 changes: 6 additions & 0 deletions BankAccountExample/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
58 changes: 58 additions & 0 deletions BankAccountExample/BankAccountExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MagyarNemzetiBank</RootNamespace>
<AssemblyName>MagyarNemzetiBank.BankAccountExample</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BankAccount\BankAccount.csproj">
<Project>{F868E5A1-F07A-4A11-A399-065DA1E192A8}</Project>
<Name>BankAccount</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
44 changes: 44 additions & 0 deletions BankAccountExample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MagyarNemzetiBank;

namespace MagyarNemzetiBank.BankAccountExample
{
class Program
{
static void Main(string[] args)
{
string validAccountNumber = "10032000-01076349";
var accountValid = new BankAccount(validAccountNumber);
System.Console.WriteLine($"{accountValid.AccountNumber}: IsValid = {accountValid.IsValid}, Bank = {accountValid.Bank}");

var accountInvalidNumber = new BankAccount("00000000-00000000-00000001");
System.Console.WriteLine($"{accountInvalidNumber.AccountNumber}: IsValid = {accountInvalidNumber.IsValid}");
try
{
System.Console.WriteLine($"Checking bank details for {accountInvalidNumber.AccountNumber}");
System.Console.WriteLine(accountInvalidNumber.Bank);
}
catch (FormatException)
{
System.Console.WriteLine($"{typeof(FormatException)} was thrown because account number was not valid");
}

var accountInvalidBank = new BankAccount("00000000-00000000");
System.Console.WriteLine($"{accountInvalidBank.AccountNumber}: IsValid = {accountInvalidBank.IsValid} (it's technically valid)");
try
{
System.Console.WriteLine($"Checking bank details for {accountInvalidBank.AccountNumber}");
System.Console.WriteLine(accountInvalidBank.Bank);
}
catch (KeyNotFoundException)
{
System.Console.WriteLine($"{typeof(KeyNotFoundException)} was thrown, because the bank account number doesn't belong to any known bank.");
}
System.Console.ReadKey();
}
}
}
36 changes: 36 additions & 0 deletions BankAccountExample/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConsoleApp1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApp1")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1a4aca5a-7461-4a21-ac51-e3f784e3cc38")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# MagyarNemzetiBank.BankAccount
This library written in pure C# checks the validity of a Hungarian bank account number and determines which bank is belongs to.

## Usage
Let's check a valid bank account:

```csharp
string validAccountNumber = "10032000-01076349";
var accountValid = new BankAccount(validAccountNumber);
System.Console.WriteLine($"{accountValid.AccountNumber}: IsValid = {accountValid.IsValid}, Bank = {accountValid.Bank}");
```

An invalid bank account will return `IsValid = false` and throws `FormatException` when `Bank` property is read:

```csharp
var accountInvalidNumber = new BankAccount("00000000-00000000-00000001");
System.Console.WriteLine($"{accountInvalidNumber.AccountNumber}: IsValid = {accountInvalidNumber.IsValid}");
try
{
System.Console.WriteLine($"Checking bank details for {accountInvalidNumber.AccountNumber}");
System.Console.WriteLine(accountInvalidNumber.Bank);
}
catch (FormatException)
{
System.Console.WriteLine($"{typeof(FormatException)} was thrown because account number was not valid");
}
```

When the syntax of the bank account number is correct, but it doesn't belong to any known bank `KeyNotFoundException` is thrown:

```csharp
var accountInvalidBank = new BankAccount("00000000-00000000");
System.Console.WriteLine($"{accountInvalidBank.AccountNumber}: IsValid = {accountInvalidBank.IsValid} (it's technically valid)");
try
{
System.Console.WriteLine($"Checking bank details for {accountInvalidBank.AccountNumber}");
System.Console.WriteLine(accountInvalidBank.Bank);
}
catch (KeyNotFoundException)
{
System.Console.WriteLine($"{typeof(KeyNotFoundException)} was thrown, because the bank account number doesn't belong to any known bank.");
}
```

Alternatively you can use the static `BankAccount.Validate(string accountNumber)` method to check if the number is syntactically correct.

## Download from Nuget
[!['nuget badge'](https://img.shields.io/nuget/v/MagyarNemzetiBank.BankAccount.svg)](https://www.nuget.org/packages/MagyarNemzetiBank.BankAccount/)

0 comments on commit aa0c1d7

Please sign in to comment.