コード例 #1
0
        public async void CreateTransactionFile_GivenMemberUploadSchemeHasZeroAnnualChargeAmount_DescriptionShouldNotContainAnnualCharge()
        {
            var organisation = A.Fake <Organisation>();
            var authority    = A.Fake <UKCompetentAuthority>();
            var scheme       = A.Fake <Scheme>();

            var memberUpload = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                123.45m,
                A.Dummy <int>(),
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                true);

            SystemTime.Freeze(new DateTime(2019, 1, 1));
            memberUpload.Submit(A.Dummy <User>());
            SystemTime.Unfreeze();

            A.CallTo(() => authority.AnnualChargeAmount).Returns(0);
            A.CallTo(() => scheme.IbisCustomerReference).Returns("WEE00000002");
            A.CallTo(() => scheme.Organisation).Returns(organisation);
            A.CallTo(() => scheme.CompetentAuthority).Returns(authority);
            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns("WEE800001H");

            var memberUploads = new List <MemberUpload>()
            {
                memberUpload
            };

            var invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            var result = await generator.CreateAsync(0, invoiceRun);

            Assert.Equal(result.IbisFile.Invoices[0].LineItems[0].Description, "Charge for producer registration submission made on 01 Jan 2019.");
        }
コード例 #2
0
        public async Task GetAllAatfObligatedDataCsvHandler_StringParameters_ReturnsFileName()
        {
            var          authorization    = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
            var          context          = A.Fake <WeeeContext>();
            var          commonDataAccess = A.Fake <ICommonDataAccess>();
            var          csvWriterFactory = A.Fake <CsvWriterFactory>();
            const int    complianceYear   = 2019;
            const string obligationType   = "B2C";
            const string aatfName         = "A1";

            SystemTime.Freeze(new DateTime(2019, 2, 1, 11, 1, 2));

            var handler = new GetAllAatfObligatedDataCsvHandler(authorization, context, csvWriterFactory, commonDataAccess);
            var request = new GetAllAatfObligatedDataCsv(complianceYear, 1, obligationType, aatfName, null, null);

            // Act
            var data = await handler.HandleAsync(request);

            // Assert
            data.FileName.Should().Be("2019_B2C_AATF obligated WEEE data_01022019_1101.csv");

            SystemTime.Unfreeze();
        }
コード例 #3
0
        public GetRemainingShipmentsHandlerTests()
        {
            SystemTime.Freeze(Today);

            movementRepository           = A.Fake <IMovementRepository>();
            shipmentRepository           = A.Fake <IShipmentInfoRepository>();
            financialGuaranteeRepository = A.Fake <IFinancialGuaranteeRepository>();

            var shipment = new TestableShipmentInfo
            {
                Id                = Guid.NewGuid(),
                NotificationId    = NotificationId,
                NumberOfShipments = MaxNumberOfShipments,
                Quantity          = 10m,
                Units             = ShipmentQuantityUnits.Tonnes
            };

            A.CallTo(() => shipmentRepository.GetByNotificationId(NotificationId)).Returns(shipment);
            A.CallTo(() => movementRepository.GetAllMovements(NotificationId)).Returns(GetShipments(TotalMovements, Today));
            A.CallTo(() => movementRepository.GetAllActiveMovements(NotificationId)).Returns(GetShipments(ActiveMovements, Today));

            handler = new GetRemainingShipmentsHandler(movementRepository, shipmentRepository, financialGuaranteeRepository);
        }
コード例 #4
0
        public async Task Execute_GivenMultipleReturnsForOrganisationInSameQuarterAndYear_OnlyMostRecentDataShouldBeReturned()
        {
            using (var db = new DatabaseWrapper())
            {
                var organisation = Organisation.CreateRegisteredCompany(fixture.Create <string>(), "1234567", null);
                var @return1     = CreateSubmittedReturn(db, organisation);

                SystemTime.Freeze(DateTime.Now.AddDays(1));
                var @return2 = ObligatedWeeeIntegrationCommon.CreateReturn(organisation, db.Model.AspNetUsers.First().Id, FacilityType.Aatf);
                @return2.UpdateSubmitted(db.Model.AspNetUsers.First().Id, false);
                SystemTime.Unfreeze();

                db.WeeeContext.Returns.Add(@return1);
                db.WeeeContext.Returns.Add(@return2);

                await db.WeeeContext.SaveChangesAsync();

                var results = await db.StoredProcedures.GetNonObligatedWeeeReceivedAtAatf(2019, null);

                results.Count(r => r.ReturnId.Equals(@return1.Id)).Should().Be(0);
                results.Count(r => r.ReturnId.Equals(@return2.Id)).Should().Be(CategoryValues().Count);
            }
        }
コード例 #5
0
        public ImportRefundTransactionTests()
        {
            transactionRepository = A.Fake <IImportNotificationTransactionRepository>();
            transactionCalculator = A.Fake <IImportNotificationTransactionCalculator>();
            assessmentRepository  = A.Fake <IImportNotificationAssessmentRepository>();
            refundTransaction     = new ImportRefundTransaction(transactionRepository, transactionCalculator, assessmentRepository);
            notificationId        = new Guid("DB476D01-2870-4322-8284-520B34D9667B");

            A.CallTo(() => transactionCalculator.TotalPaid(notificationId)).Returns(100);
            A.CallTo(() => transactionRepository.GetTransactions(notificationId))
            .Returns(new[]
            {
                ImportNotificationTransaction.PaymentRecord(notificationId, new DateTime(2015, 12, 1), 100,
                                                            PaymentMethod.Cheque, "12345", "comments"),
            });

            var assessment = new ImportNotificationAssessment(notificationId);

            A.CallTo(() => assessmentRepository.GetByNotification(notificationId))
            .Returns(assessment);

            SystemTime.Freeze(new DateTime(2016, 1, 1));
        }
コード例 #6
0
        public FinancialGuaranteeApprovalTests()
        {
            SystemTime.Freeze(today);

            repository = A.Fake <IFinancialGuaranteeRepository>();

            financialGuaranteeCollection = new FinancialGuaranteeCollection(notificationId);

            var approvedFinancialGuarantee = financialGuaranteeCollection.AddFinancialGuarantee(today.AddDays(-10));

            EntityHelper.SetEntityId(approvedFinancialGuarantee, approvedFinancialGuaranteeId);
            approvedFinancialGuarantee.Complete(today.AddDays(-9));
            approvedFinancialGuarantee.Approve(new ApprovalData(today.AddDays(-8), "123", 10, false, (decimal)12.34, (decimal)56.78));

            var newFinancialGuarantee = financialGuaranteeCollection.AddFinancialGuarantee(today.AddDays(-5));

            newFinancialGuarantee.Complete(today.AddDays(-4));
            EntityHelper.SetEntityId(newFinancialGuarantee, financialGuaranteeId);

            A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(financialGuaranteeCollection);

            approval = new FinancialGuaranteeApproval(repository);
        }
コード例 #7
0
        public void Constuctor_Always_SetsIssuedDateToNowUtc()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Scheme scheme = A.Fake <Scheme>();

            A.CallTo(() => scheme.CompetentAuthority).Returns(authority);

            List <MemberUpload> memberUploads = new List <MemberUpload>();
            MemberUpload        memberUpload1 = new MemberUpload(new Guid("A2A01A99-A97D-4219-9060-D7CDF7435114"), scheme, "data", "filename");

            memberUpload1.Submit(A.Dummy <User>());
            memberUploads.Add(memberUpload1);

            // Act
            SystemTime.Freeze(new DateTime(2015, 1, 1));
            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            SystemTime.Unfreeze();

            // Assert
            Assert.Equal(new DateTime(2015, 1, 1), invoiceRun.IssuedDate);
        }
コード例 #8
0
        public async Task Execute_GivenAatfWithApprovalDateExpectedToReportAndReturnStarted_RecordDataIsAsExpected()
        {
            using (var db = new DatabaseWrapper())
            {
                var date = new DateTime(2019, 1, 1, 11, 10, 1);
                SystemTime.Freeze(date);

                var organisation = Domain.Organisation.Organisation.CreateSoleTrader(fixture.Create <string>());

                var aatf = new Aatf(fixture.Create <string>(), GetAuthority(db), fixture.Create <string>().Substring(0, 10), AatfStatus.Approved, organisation, ObligatedWeeeIntegrationCommon.CreateAatfAddress(db), AatfSize.Large, Convert.ToDateTime("01/02/2019"), ObligatedWeeeIntegrationCommon.CreateDefaultContact(db.WeeeContext.Countries.First()), FacilityType.Aatf, 2019, db.WeeeContext.LocalAreas.First(), db.WeeeContext.PanAreas.First());

                var @return = ObligatedWeeeIntegrationCommon.CreateReturn(organisation, db.Model.AspNetUsers.First().Id, FacilityType.Aatf, 2019,
                                                                          QuarterType.Q1);

                db.WeeeContext.Returns.Add(@return);
                db.WeeeContext.Aatfs.Add(aatf);

                await db.WeeeContext.SaveChangesAsync();

                var results = await db.StoredProcedures.GetAatfAeReturnDataCsvData(2019, 1,
                                                                                   1, null, null, null, null, false);

                var record = results.First(x => x.AatfId == aatf.Id);
                record.ApprovalNumber.Should().Be(aatf.ApprovalNumber);
                record.CompetentAuthorityAbbr.Should().Be("EA");
                record.Name.Should().Be(aatf.Name);
                record.OrganisationName.Should().Be(organisation.OrganisationName);
                record.CreatedDate.Should().Be(date);
                record.ReturnStatus.Should().Be("Started");
                record.SubmittedBy.Should().BeNullOrWhiteSpace();
                record.SubmittedDate.Should().BeNull();
                record.ReSubmission.Should().Be("First submission");

                SystemTime.Unfreeze();
            }
        }
コード例 #9
0
        public async Task HandleAsync_GivenMandatoryParametersAndAllOptionalParameters_FileNameShouldBeCorrect()
        {
            UKCompetentAuthority ca        = fixture.Create <UKCompetentAuthority>();
            LocalArea            localArea = fixture.Create <LocalArea>();
            PanArea panArea = fixture.Create <PanArea>();

            GetAatfAeDetailsCsv request = new GetAatfAeDetailsCsv(fixture.Create <int>(), fixture.Create <ReportFacilityType>(), ca.Id, panArea.Id, localArea.Id, false);

            A.CallTo(() => commonDataAccess.FetchCompetentAuthorityById(request.AuthorityId.Value)).Returns(ca);

            A.CallTo(() => commonDataAccess.FetchLookup <LocalArea>(request.LocalArea.Value)).Returns(localArea);

            A.CallTo(() => commonDataAccess.FetchLookup <PanArea>(request.PanArea.Value)).Returns(panArea);

            DateTime date = new DateTime(2019, 05, 18, 11, 12, 0);

            SystemTime.Freeze(date);

            CSVFileData data = await handler.HandleAsync(request);

            data.FileName.Should().Be($"{request.ComplianceYear}_{ca.Abbreviation}_{panArea.Name}_{request.FacilityType.ToString().ToUpper()}_AATF-AE-PCS-organisation details_{date:ddMMyyyy_HHmm}.csv");

            SystemTime.Unfreeze();
        }
コード例 #10
0
        public async void NotUsingFixedDate_TimeNowIsNotWithinOneOfTheQuarterWindow_ReturnFalse()
        {
            var systemData = new SubmissionWindowClosedTests.TestSystemData();

            systemData.ToggleFixedCurrentDateUsage(false);

            A.CallTo(() => systemDataDataAccess.Get())
            .Returns(systemData);

            var timeNow = new DateTime(2016, 3, 25, 0, 0, 0);

            A.CallTo(() => quarterWindowFactory.GetQuarterWindowsForDate(A <DateTime> ._))
            .Returns(new List <QuarterWindow>());

            SystemTime.Freeze(timeNow, true);

            var handler = new IsSubmissionWindowOpenHandler(quarterWindowFactory, systemDataDataAccess);

            var result = await handler.HandleAsync(A.Dummy <IsSubmissionWindowOpen>());

            SystemTime.Unfreeze();

            Assert.False(result);
        }
コード例 #11
0
        public async void IndexGet_GiveActionExecutes_BreadcrumbShouldBeSet()
        {
            var returnId       = Guid.NewGuid();
            var organisationId = Guid.NewGuid();
            var @return        = A.Fake <ReturnData>();

            var          quarterData     = new Quarter(2019, QuarterType.Q1);
            var          quarterWindow   = QuarterWindowTestHelper.GetDefaultQuarterWindow();
            const string reportingPeriod = "2019 Q1 Jan - Mar";

            @return.Quarter       = quarterData;
            @return.QuarterWindow = quarterWindow;

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            SystemTime.Freeze(new DateTime(2019, 04, 01));
            await controller.Index(organisationId, returnId);

            SystemTime.Unfreeze();

            Assert.Equal(breadcrumb.ExternalActivity, BreadCrumbConstant.AatfReturn);

            Assert.Contains(reportingPeriod, breadcrumb.QuarterDisplayInfo);
        }
コード例 #12
0
 public NotificationShipmentTests()
 {
     // Set "today" at 2014/01/01
     SystemTime.Freeze(new DateTime(2014, 01, 01));
 }
コード例 #13
0
        public async Task CreateTransactionFile_WithOneMemberUpload_CreatesFileWithOneInvoiceWithOneLineItemWithCorrectDetails()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                123.45m,
                complianceYear,
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                false);

            SystemTime.Freeze(new DateTime(2015, 1, 1));
            memberUpload.Submit(A.Dummy <User>());
            SystemTime.Unfreeze();

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload);

            SystemTime.Freeze(new DateTime(2015, 12, 31));
            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            SystemTime.Unfreeze();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns("WEE800001H");

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            TransactionFile transactionFile = result.IbisFile;

            // Assert
            Assert.NotNull(transactionFile);
            Assert.Equal(1, transactionFile.Invoices.Count);

            Invoice invoice = transactionFile.Invoices[0];

            Assert.NotNull(invoice);

            Assert.Equal(TransactionType.Invoice, invoice.TransactionType);
            Assert.Equal("WEE800001H", invoice.TransactionReference);
            Assert.Equal(123.45m, invoice.TransactionTotal);
            Assert.Equal(null, invoice.TransactionHeaderNarrative);
            Assert.Equal(new DateTime(2015, 12, 31), invoice.TransactionDate);
            Assert.Equal(null, invoice.RelatedTransactionReference);
            Assert.Equal(CurrencyCode.GBP, invoice.CurrencyCode);
            Assert.Equal("WEE00000001", invoice.CustomerReference);

            Assert.NotNull(invoice.LineItems);
            Assert.Equal(1, invoice.LineItems.Count);

            InvoiceLineItem lineItem = invoice.LineItems[0];

            Assert.NotNull(lineItem);

            Assert.Equal(123.45m, lineItem.AmountExcludingVAT);
            Assert.Equal("Charge for producer registration submission made on 01 Jan 2015.", lineItem.Description);
            Assert.Equal("H", lineItem.AreaCode);
            Assert.Equal("H", lineItem.ContextCode);
            Assert.Equal("W", lineItem.IncomeStreamCode);
            Assert.Equal((ulong)1, lineItem.Quantity);
            Assert.Equal(UnitOfMeasure.Each, lineItem.UnitOfMeasure);
            Assert.Equal(null, lineItem.VatCode);
        }
コード例 #14
0
        public async Task Execute_GivenAatfWithApprovalDateExpectedToReportAndResubmissionCreatedAndResubmissionsRequestedWithReturnsWithVarietyOfData_RecordDataIsAsExpected()
        {
            using (var db = new DatabaseWrapper())
            {
                var date = new DateTime(2019, 1, 1, 11, 10, 1);
                SystemTime.Freeze(date);

                var organisation = Domain.Organisation.Organisation.CreateSoleTrader(fixture.Create <string>());

                var aatf = new Aatf(fixture.Create <string>(), GetAuthority(db), fixture.Create <string>().Substring(0, 10), AatfStatus.Approved, organisation, ObligatedWeeeIntegrationCommon.CreateAatfAddress(db), AatfSize.Large, Convert.ToDateTime("01/02/2019"), ObligatedWeeeIntegrationCommon.CreateDefaultContact(db.WeeeContext.Countries.First()), FacilityType.Aatf, 2019, db.WeeeContext.LocalAreas.First(), db.WeeeContext.PanAreas.First());

                var @return = ObligatedWeeeIntegrationCommon.CreateReturn(organisation, db.Model.AspNetUsers.First().Id, FacilityType.Aatf, 2019,
                                                                          QuarterType.Q1);

                db.WeeeContext.WeeeSentOn.Add(new WeeeSentOn(ObligatedWeeeIntegrationCommon.CreateAatfAddress(db),
                                                             ObligatedWeeeIntegrationCommon.CreateAatfAddress(db), aatf, @return));
                db.WeeeContext.WeeeReceived.Add(new WeeeReceived(new Scheme(organisation), aatf, @return));
                db.WeeeContext.WeeeReused.Add(new WeeeReused(aatf, @return));

                @return.UpdateSubmitted(db.Model.AspNetUsers.First().Id, false);

                var @return2 = ObligatedWeeeIntegrationCommon.CreateReturn(organisation, db.Model.AspNetUsers.First().Id, FacilityType.Aatf, 2019,
                                                                           QuarterType.Q1);

                db.WeeeContext.WeeeSentOn.Add(new WeeeSentOn(ObligatedWeeeIntegrationCommon.CreateAatfAddress(db),
                                                             ObligatedWeeeIntegrationCommon.CreateAatfAddress(db), aatf, @return2));
                db.WeeeContext.WeeeReceived.Add(new WeeeReceived(new Scheme(organisation), aatf, @return2));
                db.WeeeContext.WeeeReused.Add(new WeeeReused(aatf, @return2));

                @return2.UpdateSubmitted(db.Model.AspNetUsers.First().Id, false);

                db.WeeeContext.Aatfs.Add(aatf);
                db.WeeeContext.Returns.Add(@return);
                db.WeeeContext.Returns.Add(@return2);
                db.WeeeContext.ReturnAatfs.Add(new ReturnAatf(aatf, @return));

                await db.WeeeContext.SaveChangesAsync();

                var results = await db.StoredProcedures.GetAatfAeReturnDataCsvData(2019, 1,
                                                                                   1, null, null, null, null, true);

                var initialSubmission = results.Where(x => x.AatfId == aatf.Id).ElementAt(0);
                initialSubmission.ApprovalNumber.Should().Be(aatf.ApprovalNumber);
                initialSubmission.CompetentAuthorityAbbr.Should().Be("EA");
                initialSubmission.Name.Should().Be(aatf.Name);
                initialSubmission.OrganisationName.Should().Be(organisation.OrganisationName);
                initialSubmission.CreatedDate.Should().Be(date);
                initialSubmission.ReturnStatus.Should().Be("Submitted");
                initialSubmission.SubmittedBy.Should().Be($"{db.Model.AspNetUsers.First().FirstName} {db.Model.AspNetUsers.First().Surname}");
                initialSubmission.SubmittedDate.Should().Be(date);
                initialSubmission.ReSubmission.Should().Be("First submission");

                var resubmission = results.Where(x => x.AatfId == aatf.Id).ElementAt(1);
                resubmission.ApprovalNumber.Should().Be(aatf.ApprovalNumber);
                resubmission.CompetentAuthorityAbbr.Should().Be("EA");
                resubmission.Name.Should().Be(aatf.Name);
                resubmission.OrganisationName.Should().Be(organisation.OrganisationName);
                resubmission.CreatedDate.Should().Be(date);
                resubmission.ReturnStatus.Should().Be("Submitted");
                resubmission.SubmittedBy.Should().Be($"{db.Model.AspNetUsers.First().FirstName} {db.Model.AspNetUsers.First().Surname}");
                resubmission.SubmittedDate.Should().Be(date);
                resubmission.ReSubmission.Should().Be("Resubmission");

                SystemTime.Unfreeze();
            }
        }
コード例 #15
0
 public ReceiptDateTests()
 {
     SystemTime.Freeze(Today);
 }
コード例 #16
0
        public DaysRemainingCalculatorTests()
        {
            calculator = new DaysRemainingCalculator();

            SystemTime.Freeze(Today);
        }
コード例 #17
0
 public void Cleanup()
 {
     SystemTime.Freeze(DateTime.Now);
 }
コード例 #18
0
ファイル: MovementDateTests.cs プロジェクト: DEFRA/prsd-iws
        public MovementDateTests()
        {
            validator = A.Fake <IUpdatedMovementDateValidator>();

            SystemTime.Freeze(Today);
        }
コード例 #19
0
 public ImportMovementCommentsTests()
 {
     SystemTime.Freeze(Today);
     movement = new ImportMovement(notificationId, 52, Today);
 }
コード例 #20
0
 public CaptureViewModelTests()
 {
     SystemTime.Freeze(new DateTime(2016, 6, 1));
 }
コード例 #21
0
ファイル: RecoveryDateTests.cs プロジェクト: DEFRA/prsd-iws
 public RecoveryDateTests()
 {
     SystemTime.Freeze(Today);
 }
コード例 #22
0
        public async Task CreateTransactionFile_WithOneProducerSubmission_CreatesOneInvoiceWithOneLineItem()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                A.Dummy <decimal>(),
                complianceYear,
                scheme,
                A.Dummy <string>());

            RegisteredProducer registeredProducer = new RegisteredProducer("WEE/11AAAA11", complianceYear, scheme);

            ProducerSubmission producerSubmission = new ProducerSubmission(
                registeredProducer,
                memberUpload,
                A.Dummy <ProducerBusiness>(),
                A.Dummy <AuthorisedRepresentative>(),
                A.Dummy <DateTime>(),
                A.Dummy <decimal>(),
                A.Dummy <bool>(),
                A.Dummy <DateTime?>(),
                A.Dummy <string>(),
                A.Dummy <EEEPlacedOnMarketBandType>(),
                A.Dummy <SellingTechniqueType>(),
                A.Dummy <ObligationType>(),
                A.Dummy <AnnualTurnOverBandType>(),
                A.Dummy <List <BrandName> >(),
                A.Dummy <List <SICCode> >(),
                A.Dummy <Domain.Lookup.ChargeBandAmount>(),
                123.45m,
                A.Dummy <StatusType>());

            memberUpload.ProducerSubmissions.Add(producerSubmission);

            memberUpload.Submit(A.Dummy <User>());

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload);

            SystemTime.Freeze(new DateTime(2015, 12, 31));
            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            SystemTime.Unfreeze();

            ITransactionReferenceGenerator transactionReferenceGenerator = A.Fake <ITransactionReferenceGenerator>();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns("WEE800001H");

            ByChargeValueTransactionFileGenerator generator = new ByChargeValueTransactionFileGenerator(transactionReferenceGenerator);

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            TransactionFile transactionFile = result.IbisFile;

            // Assert
            Assert.NotNull(transactionFile);
            Assert.Equal(1, transactionFile.Invoices.Count);

            Invoice invoice = transactionFile.Invoices[0];

            Assert.NotNull(invoice);

            Assert.Equal(TransactionType.Invoice, invoice.TransactionType);
            Assert.Equal("WEE800001H", invoice.TransactionReference);
            Assert.Equal(123.45m, invoice.TransactionTotal);
            Assert.Equal(null, invoice.TransactionHeaderNarrative);
            Assert.Equal(new DateTime(2015, 12, 31), invoice.TransactionDate);
            Assert.Equal(null, invoice.RelatedTransactionReference);
            Assert.Equal(CurrencyCode.GBP, invoice.CurrencyCode);
            Assert.Equal("WEE00000001", invoice.CustomerReference);

            Assert.NotNull(invoice.LineItems);
            Assert.Equal(1, invoice.LineItems.Count);

            InvoiceLineItem lineItem = invoice.LineItems[0];

            Assert.NotNull(lineItem);

            Assert.Equal(123.45m, lineItem.AmountExcludingVAT);
            Assert.Equal("1 producer registration charge at £123.45.", lineItem.Description);
            Assert.Equal("H", lineItem.AreaCode);
            Assert.Equal("H", lineItem.ContextCode);
            Assert.Equal("W", lineItem.IncomeStreamCode);
            Assert.Equal((ulong)1, lineItem.Quantity);
            Assert.Equal(UnitOfMeasure.Each, lineItem.UnitOfMeasure);
            Assert.Equal(null, lineItem.VatCode);
        }
コード例 #23
0
        public void Setup()
        {
            SystemTime.Freeze();
            PacketFactory.Initialize <NoS0575Packet>();
            var contextBuilder =
                new DbContextOptionsBuilder <NosCoreContext>().UseInMemoryDatabase(
                    databaseName: Guid.NewGuid().ToString());

            DataAccessHelper.Instance.InitializeForTest(contextBuilder.Options);
            var _acc = new AccountDto {
                Name = "AccountTest", Password = "******".ToSha512()
            };

            _chara = new CharacterDto
            {
                CharacterId = 1,
                Name        = "TestExistingCharacter",
                Slot        = 1,
                AccountId   = _acc.AccountId,
                MapId       = 1,
                State       = CharacterState.Active
            };
            _session.InitializeAccount(_acc);

            var items = new List <Item>
            {
                new Item {
                    Type = PocketType.Main, VNum = 1012, IsDroppable = true
                },
                new Item {
                    Type = PocketType.Main, VNum = 1013
                },
                new Item {
                    Type = PocketType.Equipment, VNum = 1, ItemType = ItemType.Weapon
                },
                new Item {
                    Type = PocketType.Equipment, VNum = 2, EquipmentSlot = EquipmentType.Fairy, Element = 2
                },
                new Item {
                    Type = PocketType.Equipment, VNum = 912, ItemType = ItemType.Specialist, ReputationMinimum = 2, Element = 1
                },
                new Item {
                    Type = PocketType.Equipment, VNum = 924, ItemType = ItemType.Fashion
                }
            };
            var conf = new WorldConfiguration {
                BackpackSize = 2, MaxItemAmount = 999
            };

            _itemBuilder           = new ItemBuilderService(items, new List <IHandler <Item, Tuple <IItemInstance, UseItemPacket> > >());
            _handler               = new InventoryPacketController(conf);
            _mapItemBuilderService = new MapItemBuilderService(new List <IHandler <MapItem, Tuple <MapItem, GetPacket> > > {
                new DropHandler(), new SpChargerHandler(), new GoldDropHandler()
            });
            _map = new MapInstance(new Map
            {
                Name = "testMap",
                Data = new byte[]
                {
                    8, 0, 8, 0,
                    0, 0, 0, 0, 0, 0, 0, 0,
                    0, 1, 1, 1, 0, 0, 0, 0,
                    0, 1, 1, 1, 0, 0, 0, 0,
                    0, 1, 1, 1, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0
                }
            }
                                   , Guid.NewGuid(), false, MapInstanceType.BaseMapInstance, new List <NpcMonsterDto>(),
                                   _mapItemBuilderService, new MapNpcBuilderService(_itemBuilder, new List <ShopDto>(), new List <ShopItemDto>(), new List <NpcMonsterDto>(), new List <MapNpcDto>()),
                                   new MapMonsterBuilderService(new List <Item>(), new List <ShopDto>(), new List <ShopItemDto>(), new List <NpcMonsterDto>(), new List <MapMonsterDto>()));
            _handler.RegisterSession(_session);
            _session.SetCharacter(_chara.Adapt <Character>());
            _session.Character.MapInstance     = _map;
            _session.Character.Account         = _acc;
            _session.Character.Inventory       = new InventoryService(items, conf);
            _session.Character.ExchangeService = new ExchangeService(null, null);
        }
コード例 #24
0
 public void Cleanup()
 {
     SystemTime.Freeze(SystemTime.Now());
 }
コード例 #25
0
 public void ReturnsCorrectNumberWhenTimeInvolved()
 {
     SystemTime.Freeze(Today.AddHours(5).AddMinutes(30));
     Assert.Equal("3", calculator.Calculate(Today.AddDays(3).AddHours(5)));
 }