Skip to content

Commit 280d16a

Browse files
committed
Fixing up tests.
1 parent d845a40 commit 280d16a

File tree

7 files changed

+131
-15
lines changed

7 files changed

+131
-15
lines changed

tests/CompaniesHouse.Tests/CompaniesHouseCompanyProfileClientTests/CompaniesHouseCompanyProfileClientTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
using System;
2-
using System.Linq;
3-
using System.Net.Http;
4-
using CompaniesHouse.Tests.ResourceBuilders;
1+
using CompaniesHouse.Tests.ResourceBuilders;
52
using CompaniesHouse.UriBuilders;
63
using FluentAssertions;
74
using Moq;
85
using NUnit.Framework;
9-
using CompanyProfile = CompaniesHouse.Response.CompanyProfile.CompanyProfile;
106

117
namespace CompaniesHouse.Tests.CompaniesHouseCompanyProfileClientTests
128
{

tests/CompaniesHouse.Tests/CompaniesHouseCompanyProfileClientTests/CompanyProfileBuilder.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
using System.Linq;
2-
using CompaniesHouse.Response.CompanyProfile;
31
using AutoFixture;
4-
using Accounts = CompaniesHouse.Tests.ResourceBuilders.Accounts;
5-
using AnnualReturn = CompaniesHouse.Tests.ResourceBuilders.AnnualReturn;
6-
using CompanyProfile = CompaniesHouse.Tests.ResourceBuilders.CompanyProfile;
7-
using ConfirmationStatement = CompaniesHouse.Tests.ResourceBuilders.ConfirmationStatement;
8-
using LastAccounts = CompaniesHouse.Tests.ResourceBuilders.LastAccounts;
9-
using Officer = CompaniesHouse.Tests.ResourceBuilders.Officer;
10-
using OfficerSummary = CompaniesHouse.Tests.ResourceBuilders.OfficerSummary;
112

123
namespace CompaniesHouse.Tests.CompaniesHouseCompanyProfileClientTests
134
{
@@ -63,6 +54,15 @@ public ResourceBuilders.CompanyProfile Build(CompaniesHouseCompanyProfileClientT
6354

6455
var officerSummary = fixture.Build<ResourceBuilders.OfficerSummary>().With(x => x.Officers, officers).Create();
6556

57+
var accountingRequirement = fixture.Build<ResourceBuilders.AccountingRequirement>()
58+
.With(x => x.ForeignAccountType, "")
59+
.With(x => x.TermsOfAccountPublication, "")
60+
.Create();
61+
62+
var foreignCompanyDetails = fixture.Build<ResourceBuilders.ForeignCompanyDetails>()
63+
.With(x => x.AccountingRequirement, accountingRequirement)
64+
.Create();
65+
6666
var companyProfile = fixture.Build<ResourceBuilders.CompanyProfile>()
6767
.With(x => x.Accounts, accounts)
6868
.With(x => x.CompanyStatus, testCase.CompanyStatus)
@@ -71,6 +71,7 @@ public ResourceBuilders.CompanyProfile Build(CompaniesHouseCompanyProfileClientT
7171
.With(x => x.Type, testCase.Type)
7272
.With(x => x.OfficerSummary, officerSummary)
7373
.With(x => x.PreviousCompanyNames, previousCompanyNames)
74+
.With(x => x.ForeignCompanyDetails, foreignCompanyDetails)
7475
.Create();
7576

7677
return companyProfile;

tests/CompaniesHouse.Tests/EnumerationMappings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,20 @@ public static class EnumerationMappings
240240
{"nature-of-charge", ClassificationChargeType.NatureOfCharge}
241241
};
242242

243+
public static readonly IReadOnlyDictionary<string, TermsOfAccountPublication> PossibleTermsOfAccountPublication = new Dictionary<string, TermsOfAccountPublication>
244+
{
245+
{"", TermsOfAccountPublication.None},
246+
{"accounts-publication-date-supplied-by-company", TermsOfAccountPublication.AccountsPublicationDateSuppliedByCompany},
247+
{"accounting-publication-date-does-not-need-to-be-supplied-by-company", TermsOfAccountPublication.AccountingPublicationDateDoesNotNeedToBeSuppliedByCompany},
248+
{"accounting-reference-date-allocated-by-companies-house", TermsOfAccountPublication.AccountingReferenceDateAllocatedByCompaniesHouse},
249+
250+
};
251+
public static readonly IReadOnlyDictionary<string, ForeignAccountType> PossibleForeignAccountTypes = new Dictionary<string, ForeignAccountType>
252+
{
253+
{"", ForeignAccountType.None},
254+
{"accounting-requirements-of-originating-country-apply", ForeignAccountType.AccountingRequirementsOfOriginatingCountryApply},
255+
{"accounting-requirements-of-originating-country-do-not-apply", ForeignAccountType.AccountingRequirementsOfOriginatingCountryDoNotApply},
256+
};
243257
public static readonly IReadOnlyDictionary<string, SecuredDetailType> PossibleSecuredDetailTypes = new Dictionary<string, SecuredDetailType>
244258
{
245259
{"amount-secured", SecuredDetailType.AmountSecured},

tests/CompaniesHouse.Tests/Initializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public void OneTimeSetUp()
3131
AssertionOptions.EquivalencySteps.Insert<ComparingEnumWith<ClassificationChargeTypeMapProvider, ClassificationChargeType>>();
3232
AssertionOptions.EquivalencySteps.Insert<ComparingEnumWith<ParticularTypeMapProvider, ParticularType>>();
3333
AssertionOptions.EquivalencySteps.Insert<ComparingEnumWith<SecureDetailTypeMapProvider, SecuredDetailType>>();
34+
AssertionOptions.EquivalencySteps.Insert<ComparingEnumWith<ForeignAccountTypeMapProvider, ForeignAccountType>>();
35+
AssertionOptions.EquivalencySteps.Insert<ComparingEnumWith<TermsOfAccountPublicationMapProvider, TermsOfAccountPublication>>();
3436
}
3537
}
3638
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
using System.Collections.Generic;
22
using CompaniesHouse.Response;
3+
using CompaniesHouse.Response.CompanyProfile;
34

45
namespace CompaniesHouse.Tests.MapProviders
56
{
67
public class SecureDetailTypeMapProvider : IEnumDataMapProvider<SecuredDetailType>
78
{
89
public IReadOnlyDictionary<string, SecuredDetailType> Map => EnumerationMappings.PossibleSecuredDetailTypes;
910
}
11+
12+
public class ForeignAccountTypeMapProvider : IEnumDataMapProvider<ForeignAccountType>
13+
{
14+
public IReadOnlyDictionary<string, ForeignAccountType> Map => EnumerationMappings.PossibleForeignAccountTypes;
15+
}
16+
17+
public class TermsOfAccountPublicationMapProvider : IEnumDataMapProvider<TermsOfAccountPublication>
18+
{
19+
public IReadOnlyDictionary<string, TermsOfAccountPublication> Map => EnumerationMappings.PossibleTermsOfAccountPublication;
20+
}
1021
}

tests/CompaniesHouse.Tests/ResourceBuilders/CompanyProfile.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,69 @@ public class CompanyProfile
5555
public CompanyProfileLinks Links { get; set; }
5656

5757
public CompanyProfileBranchCompanyDetails BranchCompanyDetails { get; set; }
58+
59+
public ForeignCompanyDetails ForeignCompanyDetails { get; set; }
60+
}
61+
62+
public class ForeignCompanyDetails
63+
{
64+
public AccountingRequirement AccountingRequirement { get; set; }
65+
66+
public ForeignCompanyAccounts Accounts { get; set; }
67+
68+
public string BusinessActivity { get; set; }
69+
70+
public string CompanyType { get; set; }
71+
72+
public string GovernedBy { get; set; }
73+
74+
public bool? IsACreditFinanceInstitution { get; set; }
75+
76+
public OriginatingRegistry OriginatingRegistry { get; set; }
77+
78+
public string RegistrationNumber { get; set; }
79+
}
80+
81+
public class OriginatingRegistry
82+
{
83+
public string Country { get; set; }
84+
85+
public string Name { get; set; }
86+
}
87+
88+
public class ForeignCompanyAccounts
89+
{
90+
public ForeignCompanyPeriodFrom AccountPeriodFrom { get; set; }
91+
92+
public ForeignCompanyPeriodTo AccountPeriodTo { get; set; }
93+
94+
public MustFileWithin MustFileWithin { get; set; }
95+
96+
}
97+
98+
public class MustFileWithin
99+
{
100+
public int? Months { get; set; }
101+
}
102+
103+
public class ForeignCompanyPeriodTo
104+
{
105+
public int? Day { get; set; }
106+
107+
public int? Month { get; set; }
108+
}
109+
110+
public class ForeignCompanyPeriodFrom
111+
{
112+
public int? Day { get; set; }
113+
114+
public int? Month { get; set; }
115+
}
116+
117+
public class AccountingRequirement
118+
{
119+
public string ForeignAccountType { get; set; }
120+
121+
public string TermsOfAccountPublication { get; set; }
58122
}
59123
}

tests/CompaniesHouse.Tests/ResourceBuilders/CompanyProfileResourceBuilder.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,35 @@ public string Create()
105105
{string.Join(",", _companyProfile.SicCodes.Select(x => $@"""{x}"""))}
106106
],
107107
""type"" : ""{_companyProfile.Type}"",
108-
""undeliverable_registered_office_address"" : {_companyProfile.UndeliverableRegisteredOfficeAddress.ToString().ToLower()}
108+
""undeliverable_registered_office_address"" : {_companyProfile.UndeliverableRegisteredOfficeAddress.ToString().ToLower()},
109+
""foreign_company_details"" : {{
110+
""accounting_requirement"": {{
111+
""foreign_account_type"": ""{_companyProfile.ForeignCompanyDetails.AccountingRequirement.ForeignAccountType}"",
112+
""terms_of_account_publication"": ""{_companyProfile.ForeignCompanyDetails.AccountingRequirement.TermsOfAccountPublication}""
113+
}},
114+
""accounts"": {{
115+
""account_period_from:"": {{
116+
""day"": ""{_companyProfile.ForeignCompanyDetails.Accounts.AccountPeriodFrom.Day}"",
117+
""month"": ""{_companyProfile.ForeignCompanyDetails.Accounts.AccountPeriodFrom.Month}""
118+
}},
119+
""account_period_to"": {{
120+
""day"": ""{_companyProfile.ForeignCompanyDetails.Accounts.AccountPeriodTo.Day}"",
121+
""month"": ""{_companyProfile.ForeignCompanyDetails.Accounts.AccountPeriodTo.Month}""
122+
}},
123+
""must_file_within"": {{
124+
""months"": ""{_companyProfile.ForeignCompanyDetails.Accounts.MustFileWithin.Months}"",
125+
}}
126+
}},
127+
""business_activity"": ""{_companyProfile.ForeignCompanyDetails.BusinessActivity}"",
128+
""company_type"": ""{_companyProfile.ForeignCompanyDetails.CompanyType}"",
129+
""governed_by"": ""{_companyProfile.ForeignCompanyDetails.GovernedBy}"",
130+
""is_a_credit_finance_institution"": {_companyProfile.ForeignCompanyDetails.IsACreditFinanceInstitution.ToString().ToLower()},
131+
""originating_registry"": {{
132+
""country"": ""{_companyProfile.ForeignCompanyDetails.OriginatingRegistry.Country}"",
133+
""name"": ""{_companyProfile.ForeignCompanyDetails.OriginatingRegistry.Name}""
134+
}},
135+
""registration_number"": ""{_companyProfile.ForeignCompanyDetails.RegistrationNumber}""
136+
}}
109137
}}";
110138
}
111139

0 commit comments

Comments
 (0)