File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Algorithms.Tests/Financial Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ using Algorithms . Financial ;
2
+ using FluentAssertions ;
3
+ using NUnit . Framework ;
4
+
5
+ namespace Algorithms . Tests . Financial
6
+ {
7
+ [ TestFixture ]
8
+
9
+ public class PricePlusTaxTest
10
+ {
11
+ [ Test ]
12
+ public void Price_Plus_Tax_Test ( )
13
+ {
14
+ PricePlusTax . Calculate ( 125.50m , 0.05m ) . Should ( ) . Be ( 131.775m ) ;
15
+ PricePlusTax . Calculate ( 125.50f , 0.05f ) . Should ( ) . Be ( 131.775f ) ;
16
+
17
+ PricePlusTax . Calculate ( 100.0m , 0.25m ) . Should ( ) . Be ( 125.0m ) ;
18
+ PricePlusTax . Calculate ( 100.0f , 0.25f ) . Should ( ) . Be ( 125.0f ) ;
19
+
20
+ PricePlusTax . Calculate ( 0 , 0.25 ) . Should ( ) . Be ( 0 ) ;
21
+ PricePlusTax . Calculate ( 0.0f , 0.25f ) . Should ( ) . Be ( 0.0f ) ;
22
+ PricePlusTax . Calculate ( 0.0m , 0.25m ) . Should ( ) . Be ( 0.0m ) ;
23
+ }
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Numerics ;
3
+
4
+ namespace Algorithms . Financial
5
+ {
6
+ public static class PricePlusTax
7
+ {
8
+ public static double Calculate ( double price , double taxRate )
9
+ => price * ( 1 + taxRate ) ;
10
+
11
+ public static decimal Calculate ( decimal price , decimal taxRate )
12
+ => price * ( 1 + taxRate ) ;
13
+
14
+ public static int Calculate ( int price , int taxRate )
15
+ => price * ( 1 + taxRate ) ;
16
+
17
+ public static float Calculate ( float price , float taxRate )
18
+ => price * ( 1 + taxRate ) ;
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments