private void AssertAllModelStringsAreDefault(WasteRecoveryViewModel model)
 {
     Assert.Equal("N/A", model.MethodOfDisposal);
     AssertAllWasteRecoveryStringsAreEmpty(model);
     AssertAnnexMessageEmpty(model);
     Assert.Equal(string.Empty, model.PercentageRecoverable);
 }
示例#2
0
        public WasteRecoveryBlock(IList <MergeField> mergeFields, NotificationApplication notification, WasteRecovery wasteRecovery, WasteDisposal wasteDisposal)
        {
            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);

            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new WasteRecoveryViewModel(notification, wasteRecovery, wasteDisposal, new WasteRecoveryFormatter());

            if (notification.NotificationType == NotificationType.Disposal)
            {
                HasAnnex = false;

                MergeMainDocumentBlock();
            }
            else
            {
                HasAnnex = true;

                if (notification.WasteRecoveryInformationProvidedByImporter.GetValueOrDefault())
                {
                    HasAnnex = false;

                    MergeMainDocumentBlock();
                }
            }
        }
        public WasteRecoveryBlock(IList<MergeField> mergeFields, NotificationApplication notification, WasteRecovery wasteRecovery, WasteDisposal wasteDisposal)
        {
            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);

            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new WasteRecoveryViewModel(notification, wasteRecovery, wasteDisposal, new WasteRecoveryFormatter());
            
            if (notification.NotificationType == NotificationType.Disposal)
            {
                HasAnnex = false;

                MergeMainDocumentBlock();
            }
            else
            {
                HasAnnex = true;

                if (notification.WasteRecoveryInformationProvidedByImporter.GetValueOrDefault())
                {
                    HasAnnex = false;

                    MergeMainDocumentBlock();
                }
            }
        }
        public void CanConstructWithNullWasteRecovery()
        {
            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(), null, null, wasteRecoveryFormatter);

            Assert.Equal(string.Empty, model.PercentageRecoverable);
            Assert.Equal("N/A", model.CostAmountText);
            Assert.Equal("N/A", model.EstimatedAmountText);
            Assert.Equal("N/A", model.DisposalAmountText);
        }
        public void CanConstructWithNullWasteRecovery()
        {
            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(), null, null, wasteRecoveryFormatter);

            Assert.Equal(string.Empty, model.PercentageRecoverable);
            Assert.Equal("N/A", model.CostAmountText);
            Assert.Equal("N/A", model.EstimatedAmountText);
            Assert.Equal("N/A", model.DisposalAmountText);
        }
        public void CanConstructWithPercentageRecoverableSet()
        {
            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(), 
                new WasteRecovery(Guid.NewGuid(), 
                    new Percentage(100), 
                    new EstimatedValue(ValuePerWeightUnits.Kilogram, 10), 
                    new RecoveryCost(ValuePerWeightUnits.Kilogram, 10)),
                null, wasteRecoveryFormatter);

            AssertAnnexMessageEmpty(model);
            Assert.Equal("100%", model.PercentageRecoverable);
            Assert.Equal("N/A", model.MethodOfDisposal);
        }
        public void CanConstructWithPercentageRecoverableSet()
        {
            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(),
                                                   new WasteRecovery(Guid.NewGuid(),
                                                                     new Percentage(100),
                                                                     new EstimatedValue(ValuePerWeightUnits.Kilogram, 10),
                                                                     new RecoveryCost(ValuePerWeightUnits.Kilogram, 10)),
                                                   null, wasteRecoveryFormatter);

            AssertAnnexMessageEmpty(model);
            Assert.Equal("100%", model.PercentageRecoverable);
            Assert.Equal("N/A", model.MethodOfDisposal);
        }
        public void CanConstructWithWasteRecoveryInformationWhereDisposalInfoIsNull()
        {
            var notificationId = Guid.NewGuid();

            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(),
                new WasteRecovery(notificationId,
                    new Percentage(100),
                    new EstimatedValue(ValuePerWeightUnits.Tonne, 250),
                    new RecoveryCost(ValuePerWeightUnits.Kilogram, 100)),
                null, 
                wasteRecoveryFormatter);

            AssertAnnexMessageEmpty(model);
            Assert.Equal("100%", model.PercentageRecoverable);
            Assert.Equal("£100 per Kilogram", model.CostAmountText);
            Assert.Equal("£250 per Tonne", model.EstimatedAmountText);
            Assert.Equal("N/A", model.DisposalAmountText);
        }
        public void CanConstructWithWasteRecoveryInformationWhereDisposalInfoIsNull()
        {
            var notificationId = Guid.NewGuid();

            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(),
                                                   new WasteRecovery(notificationId,
                                                                     new Percentage(100),
                                                                     new EstimatedValue(ValuePerWeightUnits.Tonne, 250),
                                                                     new RecoveryCost(ValuePerWeightUnits.Kilogram, 100)),
                                                   null,
                                                   wasteRecoveryFormatter);

            AssertAnnexMessageEmpty(model);
            Assert.Equal("100%", model.PercentageRecoverable);
            Assert.Equal("£100 per Kilogram", model.CostAmountText);
            Assert.Equal("£250 per Tonne", model.EstimatedAmountText);
            Assert.Equal("N/A", model.DisposalAmountText);
        }
        public void CanConstructWithPercentageRecoverableAndMethodOfDisposalSet()
        {
            var methodOfDisposal = "throw in the bin";
            var notificationId = Guid.NewGuid();

            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(), 
                new WasteRecovery(notificationId,
                    new Percentage(50),
                    new EstimatedValue(ValuePerWeightUnits.Kilogram, 10),
                    new RecoveryCost(ValuePerWeightUnits.Kilogram, 10)), 
                new WasteDisposal(notificationId, 
                    methodOfDisposal, 
                    new DisposalCost(ValuePerWeightUnits.Kilogram, 10)),
                wasteRecoveryFormatter);

            AssertAnnexMessageEmpty(model);
            Assert.Equal("50%", model.PercentageRecoverable);
            Assert.Equal(methodOfDisposal, model.MethodOfDisposal);
        }
        public void CanConstructWithPercentageRecoverableAndMethodOfDisposalSet()
        {
            var methodOfDisposal = "throw in the bin";
            var notificationId   = Guid.NewGuid();

            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(),
                                                   new WasteRecovery(notificationId,
                                                                     new Percentage(50),
                                                                     new EstimatedValue(ValuePerWeightUnits.Kilogram, 10),
                                                                     new RecoveryCost(ValuePerWeightUnits.Kilogram, 10)),
                                                   new WasteDisposal(notificationId,
                                                                     methodOfDisposal,
                                                                     new DisposalCost(ValuePerWeightUnits.Kilogram, 10)),
                                                   wasteRecoveryFormatter);

            AssertAnnexMessageEmpty(model);
            Assert.Equal("50%", model.PercentageRecoverable);
            Assert.Equal(methodOfDisposal, model.MethodOfDisposal);
        }
示例#12
0
        public async Task <ActionResult> Index(Guid id, WasteRecoveryViewModel model, bool?backToOverview = null)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var existingData = await mediator.SendAsync(new GetWasteRecoveryProvider(id));

            await mediator.SendAsync(new SetWasteRecoveryProvider(model.ProvidedBy.Value, id));

            if (existingData == null || existingData.Value != model.ProvidedBy.Value)
            {
                await this.AddAuditData(id, existingData == null?NotificationAuditType.Added : NotificationAuditType.Updated, NotificationAuditScreenType.WasteRecoveryProvider);
            }

            return(model.ProvidedBy == ProvidedBy.Notifier
                ? RedirectToAction("Percentage", "WasteRecovery", new { backToOverview })
                : RedirectToAction("Index", "Home"));
        }
        public void CanConstructWithWasteRecoveryInformationWithDisposalInfo()
        {
            var methodOfDisposal = "recycle";
            var notificationId   = Guid.NewGuid();

            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(),
                                                   new WasteRecovery(notificationId,
                                                                     new Percentage(90),
                                                                     new EstimatedValue(ValuePerWeightUnits.Tonne, 110),
                                                                     new RecoveryCost(ValuePerWeightUnits.Kilogram, 100)),
                                                   new WasteDisposal(notificationId,
                                                                     methodOfDisposal,
                                                                     new DisposalCost(ValuePerWeightUnits.Kilogram, 90)),
                                                   wasteRecoveryFormatter);

            AssertAnnexMessageEmpty(model);
            Assert.Equal("90%", model.PercentageRecoverable);
            Assert.Equal(methodOfDisposal, model.MethodOfDisposal);
            Assert.Equal("£100 per Kilogram", model.CostAmountText);
            Assert.Equal("£90 per Kilogram", model.DisposalAmountText);
            Assert.Equal("£110 per Tonne", model.EstimatedAmountText);
        }
        public void CanConstructWithWasteRecoveryInformationWithDisposalInfo()
        {
            var methodOfDisposal = "recycle";
            var notificationId = Guid.NewGuid();

            var model = new WasteRecoveryViewModel(new TestableNotificationApplication(),
                new WasteRecovery(notificationId,
                    new Percentage(90),
                    new EstimatedValue(ValuePerWeightUnits.Tonne, 110),
                    new RecoveryCost(ValuePerWeightUnits.Kilogram, 100)),
                new WasteDisposal(notificationId,
                    methodOfDisposal,
                    new DisposalCost(ValuePerWeightUnits.Kilogram, 90)),
                wasteRecoveryFormatter);

            AssertAnnexMessageEmpty(model);
            Assert.Equal("90%", model.PercentageRecoverable);
            Assert.Equal(methodOfDisposal, model.MethodOfDisposal);
            Assert.Equal("£100 per Kilogram", model.CostAmountText);
            Assert.Equal("£90 per Kilogram", model.DisposalAmountText);
            Assert.Equal("£110 per Tonne", model.EstimatedAmountText);
        }
 private void AssertAllWasteRecoveryStringsAreEmpty(WasteRecoveryViewModel model)
 {
     Assert.Equal(string.Empty, model.CostAmountText);
     Assert.Equal(string.Empty, model.DisposalAmountText);
     Assert.Equal(string.Empty, model.EstimatedAmountText);
 }
 private void AssertAllModelStringsAreDefault(WasteRecoveryViewModel model)
 {
     Assert.Equal("N/A", model.MethodOfDisposal);
     AssertAllWasteRecoveryStringsAreEmpty(model);
     AssertAnnexMessageEmpty(model);
     Assert.Equal(string.Empty, model.PercentageRecoverable);
 }
 private void AssertAnnexMessageEmpty(WasteRecoveryViewModel model)
 {
     Assert.Equal(string.Empty, model.AnnexMessage);
 }
        public void CanConstructWithNullNotification()
        {
            var model = new WasteRecoveryViewModel(null, null, null, wasteRecoveryFormatter);

            AssertAllModelStringsAreDefault(model);
        }
        public void CanConstructWithNullNotification()
        {
            var model = new WasteRecoveryViewModel(null, null, null, wasteRecoveryFormatter);

            AssertAllModelStringsAreDefault(model);
        }
 private void AssertAnnexMessageEmpty(WasteRecoveryViewModel model)
 {
     Assert.Equal(string.Empty, model.AnnexMessage);
 }
 private void AssertAllWasteRecoveryStringsAreEmpty(WasteRecoveryViewModel model)
 {
     Assert.Equal(string.Empty, model.CostAmountText);
     Assert.Equal(string.Empty, model.DisposalAmountText);
     Assert.Equal(string.Empty, model.EstimatedAmountText);
 }