Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Complete refactoring of the Account example
- Loading branch information
Tom Janssens
authored and
Tom Janssens
committed
Nov 13, 2009
1 parent
cd187e0
commit 65cad7f
Showing
18 changed files
with
289 additions
and
154 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
Be.Corebvba.Aubergine.ConsoleRunner/Be.Corebvba.Aubergine.ConsoleRunner.csproj.user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<StartArguments>-html website\stories\*.txt</StartArguments> | ||
<StartArguments>accounts\stories\*.txt</StartArguments> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<StartArguments>-html website\stories\*.txt</StartArguments> | ||
<StartArguments>accounts\stories\*.txt</StartArguments> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
Be.Corebvba.Aubergine.Examples/Accounts/SoftwareToTest/Account.cs
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
Be.Corebvba.Aubergine.Examples/Accounts/SoftwareToTest/Model/Account.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Be.Corebvba.Aubergine.Examples.Accounts.SoftwareToTest.Model | ||
{ | ||
public class Account | ||
{ | ||
public Account() | ||
{ | ||
Balance = 0; | ||
} | ||
|
||
public User Owner { get; set; } | ||
|
||
public Decimal Balance { get; set; } | ||
|
||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Be.Corebvba.Aubergine.Examples/Accounts/SoftwareToTest/Model/Transaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Be.Corebvba.Aubergine.Examples.Accounts.SoftwareToTest.Model | ||
{ | ||
public class ProcessStatus | ||
{ | ||
public bool Success { get; set; } | ||
public string Message { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Be.Corebvba.Aubergine.Examples/Accounts/SoftwareToTest/Model/User.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Be.Corebvba.Aubergine.Examples.Accounts.SoftwareToTest.Model | ||
{ | ||
public class User | ||
{ | ||
public string Name { get; set; } | ||
public string Password { get; set; } | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Be.Corebvba.Aubergine.Examples/Accounts/SoftwareToTest/Services/AccountService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Be.Corebvba.Aubergine.Examples.Accounts.SoftwareToTest.Model; | ||
|
||
namespace Be.Corebvba.Aubergine.Examples.Accounts.SoftwareToTest.Services | ||
{ | ||
public class AccountService | ||
{ | ||
public ProcessStatus AuthenticateUser(User user) | ||
{ | ||
if (user.Name == "Neo" && user.Password == "Red pill") | ||
return new ProcessStatus() { Message = "Welcome " + user.Name, Success = true }; | ||
else | ||
return new ProcessStatus() { Message = "Wrong username or password", Success = false }; | ||
|
||
} | ||
|
||
public ProcessStatus AuthenticateUserForAccount(Account a, User u) | ||
{ | ||
var x = AuthenticateUser(u); | ||
if (!x.Success) return x; | ||
if (a.Owner == u) | ||
return new ProcessStatus() { Success = true }; | ||
else | ||
return new ProcessStatus() { Message ="Access to this account is not allowed", Success = false }; | ||
|
||
} | ||
|
||
|
||
public ProcessStatus Transfer(User u,decimal amount, Account From,Account ToAccount) | ||
{ | ||
var x = AuthenticateUserForAccount(From,u); | ||
if (!x.Success) return x; | ||
|
||
if (From.Balance < amount) | ||
return new ProcessStatus() { Message = "There is not enough money available on the account", Success = false }; | ||
|
||
From.Balance -= amount; | ||
ToAccount.Balance += amount; | ||
|
||
return new ProcessStatus() { Message = amount.ToString() + " was transferred",Success = true }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.