public async Task CreateCustomerFile_WithFileID_CreatesFileWithCorrectFileID() { // Arrange var authority = A.Dummy <UKCompetentAuthority>(); var address = new Address( "1 High Street", null, "Some town", "Some county", "Post code", new Country(Guid.NewGuid(), "UK - England"), "01234 567890", "*****@*****.**"); var contact = new Contact("John", "Smith", "Manager"); var organisation = Organisation.CreateSoleTrader("Test organisation"); var scheme = new Scheme(organisation); scheme.UpdateScheme( "Test scheme", "WEE/AA1111AA/SCH", "WEE00000001", A.Dummy <ObligationType>(), authority); scheme.AddOrUpdateMainContactPerson(contact); scheme.AddOrUpdateAddress(address); var complianceYear = A.Dummy <int>(); var memberUpload = new MemberUpload( A.Dummy <Guid>(), A.Dummy <string>(), A.Dummy <List <MemberUploadError> >(), A.Dummy <decimal>(), complianceYear, scheme, A.Dummy <string>()); memberUpload.Submit(A.Dummy <User>()); var memberUploads = new List <MemberUpload> { memberUpload }; var invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>()); var generator = new BySchemeCustomerFileGenerator(); ulong id = 12345; // Act var result = await generator.CreateAsync(id, invoiceRun); var customerFile = result.IbisFile; // Assert Assert.Equal((ulong)12345, customerFile.FileID); }
public void HasAddress_GivenAddress_TrueShouldBeReturned() { var scheme = new Scheme(Guid.Empty); var address = new Address("address1", "address2", "town", "county", "postcode", A.Dummy <Country>(), "telephone", "email"); scheme.AddOrUpdateAddress(address); scheme.HasAddress.Should().BeTrue(); }
public async Task CreateCustomerFile_WithOneMemberUpload_CreatesOneCustomer() { // Arrange var authority = A.Dummy <UKCompetentAuthority>(); var address = new Address( "1 High Street", null, "Some town", "Some county", "Post code", new Country(Guid.NewGuid(), "UK - England"), "01234 567890", "*****@*****.**"); var contact = new Contact("John", "Smith", "Manager"); var organisation = Organisation.CreateSoleTrader("Test organisation"); var scheme = new Scheme(organisation); scheme.UpdateScheme( "Test scheme", "WEE/AA1111AA/SCH", "WEE00000001", A.Dummy <ObligationType>(), authority); scheme.AddOrUpdateAddress(address); scheme.AddOrUpdateMainContactPerson(contact); var complianceYear = A.Dummy <int>(); var memberUpload = new MemberUpload( A.Dummy <Guid>(), A.Dummy <string>(), A.Dummy <List <MemberUploadError> >(), A.Dummy <decimal>(), complianceYear, scheme, A.Dummy <string>(), A.Dummy <string>(), false); memberUpload.Submit(A.Dummy <User>()); var memberUploads = new List <MemberUpload> { memberUpload }; var invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>()); var generator = new BySchemeCustomerFileGenerator(); // Act var result = await generator.CreateAsync(0, invoiceRun); var customerFile = result.IbisFile; // Assert Assert.NotNull(customerFile); Assert.Equal(1, customerFile.Customers.Count); var customer = customerFile.Customers[0]; Assert.NotNull(customer); Assert.Equal("WEE00000001", customer.CustomerReference); Assert.Equal("Test organisation", customer.Name); Assert.NotNull(customer.Address); Assert.Equal("John Smith", customer.Address.AddressLine1); Assert.Equal("1 High Street", customer.Address.AddressLine2); Assert.Equal(null, customer.Address.AddressLine3); Assert.Equal(null, customer.Address.AddressLine4); Assert.Equal("Some town", customer.Address.AddressLine5); Assert.Equal("Some county", customer.Address.AddressLine6); Assert.Equal("Post code", customer.Address.PostCode); }
public async Task CreateCustomerFile_WithTwoMemberUploadsForDifferentSchemes_CreatesTwoCustomers() { // Arrange var authority = A.Dummy <UKCompetentAuthority>(); var address1 = new Address( "1 High Street", null, "Some town", "Some county", "Post code", new Country(Guid.NewGuid(), "UK - England"), "01234 567890", "*****@*****.**"); var organisation1 = Organisation.CreateSoleTrader("Test organisation 1"); var scheme1 = new Scheme(organisation1); scheme1.UpdateScheme( "Test scheme 2", "WEE/AA1111AA/SCH", "WEE00000001", A.Dummy <ObligationType>(), authority); scheme1.AddOrUpdateMainContactPerson(A.Fake <Contact>()); scheme1.AddOrUpdateAddress(address1); var complianceYear1 = A.Dummy <int>(); var memberUpload1 = new MemberUpload( A.Dummy <Guid>(), A.Dummy <string>(), A.Dummy <List <MemberUploadError> >(), A.Dummy <decimal>(), complianceYear1, scheme1, A.Dummy <string>(), A.Dummy <string>(), false); memberUpload1.Submit(A.Dummy <User>()); var address2 = new Address( "2 High Street", null, "Some town", "Some county", "Post code", new Country(Guid.NewGuid(), "UK - England"), "01234 567890", "*****@*****.**"); var organisation2 = Organisation.CreateSoleTrader("Test organisation 2"); var scheme2 = new Scheme(organisation2); scheme2.UpdateScheme( "Test scheme 2", "WEE/BB2222BB/SCH", "WEE00000002", A.Dummy <ObligationType>(), authority); scheme2.AddOrUpdateAddress(address2); scheme2.AddOrUpdateMainContactPerson(A.Fake <Contact>()); var complianceYear2 = A.Dummy <int>(); var memberUpload2 = new MemberUpload( A.Dummy <Guid>(), A.Dummy <string>(), A.Dummy <List <MemberUploadError> >(), A.Dummy <decimal>(), complianceYear2, scheme2, A.Dummy <string>(), A.Dummy <string>(), false); memberUpload2.Submit(A.Dummy <User>()); var memberUploads = new List <MemberUpload> { memberUpload1, memberUpload2 }; var invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>()); var generator = new BySchemeCustomerFileGenerator(); // Act var result = await generator.CreateAsync(0, invoiceRun); var customerFile = result.IbisFile; // Assert Assert.NotNull(customerFile); Assert.Equal(2, customerFile.Customers.Count); var customer1 = customerFile.Customers[0]; Assert.NotNull(customer1); Assert.Equal("WEE00000001", customer1.CustomerReference); var customer2 = customerFile.Customers[1]; Assert.NotNull(customer2); Assert.Equal("WEE00000002", customer2.CustomerReference); }