-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
114 lines (96 loc) · 4.33 KB
/
Copy pathProgram.cs
File metadata and controls
114 lines (96 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
Welcome to the Xero technical excercise!
---------------------------------------------------------------------------------
The test consists of a small invoice application that has a number of issues.
Your job is to fix them and make sure you can perform the functions in each method below.
Note your first job is to get the solution compiling!
Rules
---------------------------------------------------------------------------------
* The entire solution must be written in C# (any version)
* You can modify any of the code in this solution, split out classes, add projects etc
* You can modify Invoice and InvoiceLine, rename and add methods, change property types (hint)
* Feel free to use any libraries or frameworks you like as long as they are .net based
* Feel free to write tests (hint)
* Show off your skills!
Good luck :)
When you have finished the solution please zip it up and email it back to the recruiter or developer who sent it to you
*/
using log4net;
using SimpleInjector;
using System;
using XeroInvoicing.Operations;
using XeroInvoicing.Services;
namespace XeroTechnicalTest
{
public class Program
{
// logs are stored in current working directory i.e. /bin/Debug folder
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
static void Main(string[] args)
{
bool endApp = false;
var container = RegisterServices();
var service = container.GetInstance<InvoiceService>();
Console.WriteLine("Welcome to Xero Tech Test!");
try
{
while (!endApp)
{
Console.WriteLine($"Please choose an operation (from the list below) to perform:{Environment.NewLine}" +
$"1. CreateInvoiceWithOneItem{Environment.NewLine}" +
$"2. CreateInvoiceWithMultipleItemsAndQuantities{Environment.NewLine}" +
$"3. RemoveItem{Environment.NewLine}" +
$"4. MergeInvoices{Environment.NewLine}" +
$"5. CloneInvoice{Environment.NewLine}" +
$"6. InvoiceToString{Environment.NewLine}" +
$"7. Exit Application");
var option = Console.ReadKey(true).Key;
switch (option)
{
case ConsoleKey.D1:
service.CreateInvoiceWithOneItem().Wait();
break;
case ConsoleKey.D2:
service.CreateInvoiceWithMultipleItemsAndQuantities().Wait();
break;
case ConsoleKey.D3:
service.RemoveItem().Wait();
break;
case ConsoleKey.D4:
service.MergeInvoices().Wait();
break;
case ConsoleKey.D5:
service.CloneInvoice().Wait();
break;
case ConsoleKey.D6:
service.InvoiceToString();
break;
case ConsoleKey.D7:
Environment.Exit(0);
break;
default:
Console.WriteLine("Please provide a valid input");
break;
}
Console.WriteLine("Press Enter to continue or Esc to exit the app");
if (Console.ReadKey(true).Key == ConsoleKey.Escape) endApp = true;
Console.Clear();
}
return;
}
catch (Exception ex)
{
log.Error($"{Environment.NewLine} Error: {ex.InnerException.Message}");
Console.ReadLine();
}
}
static Container RegisterServices()
{
// register loosely coupled classes
var container = new Container();
container.Register<IInvoiceOperations, InvoiceOperations>();
container.Register<IInvoiceService, InvoiceService>();
return container;
}
}
}