Esempio n. 1
0
        public void Map_GivenValidSource_PropertiesShouldBeMapped()
        {
            var obligatedTonnage = new ObligatedCategoryValue()
            {
                B2B        = "20",
                B2C        = "30",
                CategoryId = 1
            };

            var transfer = new ReturnAndAatfToSentOnRemoveSiteViewModelMapTransfer()
            {
                ReturnId       = Guid.NewGuid(),
                AatfId         = Guid.NewGuid(),
                OrganisationId = Guid.NewGuid(),
                WeeeSentOn     = WeeeSentOn()
            };

            A.CallTo(() => tonnageUtilities.SumObligatedValues(transfer.WeeeSentOn.Tonnages)).Returns(obligatedTonnage);

            var result = mapper.Map(transfer);

            result.OrganisationId.Should().Be(transfer.OrganisationId);
            result.ReturnId.Should().Be(transfer.ReturnId);
            result.AatfId.Should().Be(transfer.AatfId);
            result.WeeeSentOn.Should().BeEquivalentTo(transfer.WeeeSentOn);
            result.TonnageB2B.Should().Be(obligatedTonnage.B2B);
            result.TonnageB2C.Should().Be(obligatedTonnage.B2C);
        }
Esempio n. 2
0
        public async void IndexGet_ProvidedTempDataForCopyPasteValues_MapperShouldReturnViewModelWithCopyPasteValues()
        {
            string     siteName       = "SiteName";
            Guid       returnId       = Guid.NewGuid();
            Guid       organisationId = Guid.NewGuid();
            Guid       aatfId         = Guid.NewGuid();
            Guid       weeeSentOnId   = Guid.NewGuid();
            ReturnData returnData     = A.Fake <ReturnData>();
            string     b2bContent     = "1\r\n2\r\n3\r\n4\r\n";
            string     b2cContent     = "1\r\n2\r\n3\r\n4\r\n";

            ObligatedCategoryValue obligatedCategoryValue = new ObligatedCategoryValue()
            {
                B2B = b2bContent, B2C = b2cContent
            };

            TempDataDictionary tempdata = new TempDataDictionary {
                { "pastedValues", obligatedCategoryValue }
            };

            controller.TempData = tempdata;

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> .That.Matches(r => r.ReturnId.Equals(returnId)))).Returns(returnData);

            await controller.Index(returnId, organisationId, weeeSentOnId, aatfId, siteName);

            A.CallTo(() => mapper.Map(A <ReturnToObligatedViewModelMapTransfer> .That.Matches(t => t.ReturnId.Equals(returnId) && t.AatfId.Equals(aatfId) && t.WeeeSentOnId.Equals(weeeSentOnId) && t.OrganisationId.Equals(organisationId) && t.SiteName.Equals(siteName) && t.ReturnData.Equals(returnData) && t.PastedData == obligatedCategoryValue))).MustHaveHappened(Repeated.Exactly.Once);
        }
Esempio n. 3
0
        public virtual async Task <ActionResult> Index(ObligatedSentOnValuesCopyPasteViewModel viewModel)
        {
            string b2bContent = viewModel.B2bPastedValues.First();
            string b2cContent = viewModel.B2cPastedValues.First();

            if (!string.IsNullOrEmpty(b2bContent) || !string.IsNullOrEmpty(b2cContent))
            {
                TempData["pastedValues"] = new ObligatedCategoryValue()
                {
                    B2B = b2bContent, B2C = b2cContent
                };
            }

            return(await Task.Run <ActionResult>(() => AatfRedirect.ObligatedSentOn(viewModel.SiteName, viewModel.OrganisationId, viewModel.AatfId, viewModel.ReturnId, viewModel.WeeeSentOnId, viewModel.IsEditDetails.Value, viewModel.IsEditTonnage.Value)));
        }
Esempio n. 4
0
        public void GivenSource_AatfSchemeDataPropertyShouldBeSet()
        {
            var schemeData = new SchemeData()
            {
                ApprovalName = "ABC123"
            };

            var obligatedReceivedValues = new ObligatedCategoryValue("25.00", "50.00");

            var aatfSchemeData = new AatfSchemeData(schemeData, obligatedReceivedValues, "ABC123");

            aatfSchemeData.Scheme.Should().Be(schemeData);
            aatfSchemeData.ApprovalName.Should().Be("ABC123");
            aatfSchemeData.Received.B2C.Should().Be(obligatedReceivedValues.B2C);
            aatfSchemeData.Received.B2B.Should().Be(obligatedReceivedValues.B2B);
        }
Esempio n. 5
0
        public void Map_GivenNoTonnages_TonnagesShouldBeSetToDash()
        {
            var obligatedTonnage = new ObligatedCategoryValue()
            {
                B2B        = "-",
                B2C        = "-",
                CategoryId = 1
            };

            var transfer = ReturnAndAatfToSentOnRemoveSiteViewModelMapTransfer();

            A.CallTo(() => tonnageUtilities.SumObligatedValues(transfer.WeeeSentOn.Tonnages)).Returns(obligatedTonnage);

            var result = mapper.Map(transfer);

            result.TonnageB2B.Should().Be("-");
            result.TonnageB2C.Should().Be("-");
        }
        public virtual async Task <ActionResult> Index(ObligatedValuesCopyPasteViewModel viewModel)
        {
            var b2bContent = viewModel.B2bPastedValues.First();
            var b2cContent = viewModel.B2cPastedValues.First();

            if (!string.IsNullOrEmpty(b2bContent) || !string.IsNullOrEmpty(b2cContent))
            {
                TempData["pastedValues"] = new ObligatedCategoryValue()
                {
                    B2B = b2bContent, B2C = b2cContent
                };
            }

            if (viewModel.Type == ObligatedType.Reused)
            {
                return(await Task.Run <ActionResult>(() => AatfRedirect.ObligatedReused(viewModel.ReturnId, viewModel.AatfId)));
            }

            return(await Task.Run <ActionResult>(() => AatfRedirect.ObligatedReceived(viewModel.ReturnId, viewModel.AatfId, viewModel.SchemeId)));
        }
        private void SetObligatedValues(ReturnData source)
        {
            if (source.Aatfs != null)
            {
                foreach (var aatf in source.Aatfs)
                {
                    var weeeReceivedData = source.ObligatedWeeeReceivedData.Where(s => s.Aatf.Id == aatf.Id).ToList();
                    var weeeReusedData   = source.ObligatedWeeeReusedData.Where(s => s.Aatf.Id == aatf.Id).ToList();
                    var weeeSentOnData   = source.ObligatedWeeeSentOnData.Where(s => s.Aatf.Id == aatf.Id).ToList();

                    var schemeData = new List <AatfSchemeData>();

                    foreach (var scheme in source.SchemeDataItems)
                    {
                        var schemeList = weeeReceivedData.Where(s => s.Scheme.Id == scheme.Id && s.Aatf.Id == aatf.Id).ToList();

                        var obligatedReceivedValues = new ObligatedCategoryValue
                        {
                            B2B = tonnageUtilities.SumObligatedValues(schemeList).B2B,
                            B2C = tonnageUtilities.SumObligatedValues(schemeList).B2C
                        };

                        var aatfSchemeData = new AatfSchemeData(scheme, obligatedReceivedValues, scheme.ApprovalName);
                        schemeData.Add(aatfSchemeData);
                    }

                    var obligatedData = new AatfObligatedData(aatf, schemeData)
                    {
                        WeeeReceived = tonnageUtilities.SumObligatedValues(weeeReceivedData),
                        WeeeReused   = tonnageUtilities.SumObligatedValues(weeeReusedData),
                        WeeeSentOn   = tonnageUtilities.SumObligatedValues(weeeSentOnData)
                    };

                    AatfObligatedData.Add(obligatedData);
                }
            }
        }