main
1using System;
2using developwithpassion.bdd.contexts;
3using Gorilla.Commons.Testing;
4using gorilla.commons.utility;
5using Gorilla.Commons.Utility;
6using MoMoney.Domain.Accounting;
7using MoMoney.Domain.Core;
8using MoMoney.Domain.repositories;
9using MoMoney.DTO;
10using MoMoney.Service.Contracts.Application;
11
12namespace MoMoney.Service.Application
13{
14 public class AddNewIncomeCommandSpecs {}
15
16 [Concern(typeof (AddNewIncomeCommand))]
17 public abstract class when_adding_a_new_income : concerns_for<IAddNewIncomeCommand, AddNewIncomeCommand>
18 {
19 context c = () =>
20 {
21 notification = the_dependency<Notification>();
22 tasks = the_dependency<IGetTheCurrentCustomerQuery>();
23 all_income = the_dependency<IIncomeRepository>();
24 companies = the_dependency<ICompanyRepository>();
25 };
26
27 static protected Notification notification;
28 static protected IGetTheCurrentCustomerQuery tasks;
29 static protected IIncomeRepository all_income;
30 static protected ICompanyRepository companies;
31 }
32
33 [Concern(typeof (AddNewIncomeCommand))]
34 public class when_the_same_income_has_already_been_added : when_adding_a_new_income
35 {
36 it should_inform_you_that_you_have_already_added_it =
37 () => notification.was_told_to(x => x.notify("You have already submitted this income"));
38
39 context c = () =>
40 {
41 var a_company = an<ICompany>();
42 var matching_income = an<IIncome>();
43 var today = new Date(2008, 12, 26);
44 Id<Guid> id = Guid.NewGuid();
45
46 income = new IncomeSubmissionDTO
47 {
48 amount = 100.00,
49 company_id = id,
50 recieved_date = today,
51 };
52
53 when_the(matching_income).is_asked_for(x => x.amount_tendered).it_will_return(100.as_money());
54 when_the(matching_income).is_asked_for(x => x.company).it_will_return(a_company);
55 when_the(matching_income).is_asked_for(x => x.date_of_issue).it_will_return(today);
56 when_the(a_company).is_asked_for(x => x.id).it_will_return(id);
57 when_the(all_income).is_told_to(x => x.all()).it_will_return(matching_income);
58 };
59
60 because b = () => sut.run(income);
61
62 static IncomeSubmissionDTO income;
63 }
64}