예제 #1
0
        public async void DoesNotDeductChargeFromMemberUpload_WhenAlreadyInvoiced()
        {
            // Arrange
            var builder = new RemoveProducerHandlerBuilder();

            var memberUpload = new MemberUpload(A.Dummy <Guid>(), A.Dummy <string>(), null, 100, A.Dummy <int>(), A.Dummy <Scheme>(), A.Dummy <string>(), null, A.Dummy <bool>());

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

            var producerSubmission = A.Fake <ProducerSubmission>();

            A.CallTo(() => producerSubmission.ChargeThisUpdate)
            .Returns(20);
            A.CallTo(() => producerSubmission.MemberUpload)
            .Returns(memberUpload);

            A.CallTo(() => builder.RemoveProducerDataAccess.GetProducerSubmissionsForRegisteredProducer(A <Guid> ._))
            .Returns(new[] { producerSubmission });

            // Act
            await builder.Build().HandleAsync(A.Dummy <RemoveProducer>());

            // Assert
            A.CallTo(() => builder.RemoveProducerDataAccess.GetProducerSubmissionsForRegisteredProducer(A <Guid> ._))
            .MustHaveHappened();

            Assert.Equal(100, memberUpload.TotalCharges);
        }
예제 #2
0
        public void AssignToInvoiceRun_SetsProducerSubmissionAsInvoiced()
        {
            Scheme       scheme       = A.Fake <Scheme>();
            MemberUpload memberUpload = new MemberUpload(A.Dummy <Guid>(), "data", null, 100, 2015, scheme, "fileName");

            var registeredProducer = new RegisteredProducer("PRN", 2015, scheme);

            var producer = new ProducerSubmission(
                registeredProducer,
                memberUpload,
                new ProducerBusiness(),
                null,
                new DateTime(2015, 1, 1),
                0,
                false,
                null,
                "Trading Name 1",
                EEEPlacedOnMarketBandType.Lessthan5TEEEplacedonmarket,
                SellingTechniqueType.Both,
                ObligationType.Both,
                AnnualTurnOverBandType.Greaterthanonemillionpounds,
                new List <BrandName>(),
                new List <SICCode>(),
                A.Dummy <ChargeBandAmount>(),
                0,
                A.Dummy <StatusType>());

            memberUpload.ProducerSubmissions.Add(producer);
            memberUpload.Submit(A.Dummy <User>());

            memberUpload.AssignToInvoiceRun(A.Dummy <InvoiceRun>());

            Assert.True(producer.Invoiced);
        }
예제 #3
0
        public void AssignToInvoiceRun_ForUnsubmittedMemberUpload_ThrowsInvalidOperationException()
        {
            Scheme       scheme       = A.Fake <Scheme>();
            MemberUpload memberUpload = new MemberUpload(new Guid("A2A01A99-A97D-4219-9060-D7CDF7435114"), scheme, "data", "filename");

            Assert.Throws <InvalidOperationException>(() => memberUpload.AssignToInvoiceRun(A.Dummy <InvoiceRun>()));
        }
        public void AssignToInvoiceRun_DoesNotSetRemovedProducerSubmissionAsInvoiced()
        {
            Scheme scheme = A.Fake<Scheme>();
            MemberUpload memberUpload = new MemberUpload(A.Dummy<Guid>(), "data", null, 100, 2015, scheme, "fileName");

            var registeredProducer = new RegisteredProducer("PRN", 2015, scheme);
            registeredProducer.Remove();

            var producer = new ProducerSubmission(
                registeredProducer,
                memberUpload,
                new ProducerBusiness(),
                null,
                new DateTime(2015, 1, 1),
                0,
                false,
                null,
                "Trading Name 1",
                EEEPlacedOnMarketBandType.Lessthan5TEEEplacedonmarket,
                SellingTechniqueType.Both,
                ObligationType.Both,
                AnnualTurnOverBandType.Greaterthanonemillionpounds,
                new List<BrandName>(),
                new List<SICCode>(),
                A.Dummy<ChargeBandAmount>(),
                0);

            memberUpload.ProducerSubmissions.Add(producer);
            memberUpload.Submit(A.Dummy<User>());

            memberUpload.AssignToInvoiceRun(A.Dummy<InvoiceRun>());

            Assert.False(producer.Invoiced);
        }
        public void AssignToInvoiceRun_ForUnsubmittedMemberUpload_ThrowsInvalidOperationException()
        {
            Scheme scheme = A.Fake<Scheme>();
            MemberUpload memberUpload = new MemberUpload(new Guid("A2A01A99-A97D-4219-9060-D7CDF7435114"), scheme, "data", "filename");

            Assert.Throws<InvalidOperationException>(() => memberUpload.AssignToInvoiceRun(A.Dummy<InvoiceRun>()));
        }