public void GetFundOfMandates_ShouldReturnFundsOfMandatesDataWhenXMLHasData() { //Act FundsOfMandatesData fundsOfMandatesData = portfolioServices.GetFundOfMandates(path); //Assert fundsOfMandatesData.Should().NotBeNull(); }
public void CalculateMandate_ShouldNotReturnMandate_WhenInstrumentCodeDoesNotMatch() { //Arrange FundsOfMandatesData fundsOfMandatesData = portfolioServices.GetFundOfMandates(path); string positioncode = "NL0000009165"; decimal positionValue = 12345; int expectedCount = 0; //Act int actualMandateCount = portfolioServices.CalculateMandate(positioncode, positionValue, fundsOfMandatesData).Count; //Assert actualMandateCount.Should().Be(expectedCount); }
/// <summary> /// Method Read Funds XML file and read its data and set Domain Classes accordingly. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public List <FundOfMandates> ReadFundOfMandatesFile(string fileName) { try { List <FundOfMandates> funds = null; StreamReader reader = null; FundsOfMandatesData fundsOfMandatesData = null; XmlSerializer serealizer = new XmlSerializer(typeof(FundsOfMandatesData)); using (reader = new StreamReader(fileName)) { fundsOfMandatesData = (FundsOfMandatesData)serealizer.Deserialize(reader); } //WE CAN ALSO PERFORM SCHEMA VALIDATION OVER XML AND ITS DATA BUT DUE TO DOWNLOAD RESTRICTIONS , I MANUALLY WROTE ENTIRE SCHEMA WITHOUT TAKING CONSIDERATION ON NAMESPACES. //DUE TO CHANGE IN NAMESPACES SCHEMA VALIDATION WILL FAIL AND HENCE NOT PERFORMING IT. //HENCE NOT HANDLING SCHEMA VALIDATION HERE. if (fundsOfMandatesData == null) { //Log error throw new Exception("UnExpected Error. Please check that file contains data correctly."); } else if (fundsOfMandatesData != null && fundsOfMandatesData.FundsOfMandates.Length == 0) { //Log error throw new Exception("Unable to Read blank FundOfMandatesFile. Please check the file."); } else { funds = fundsOfMandatesData.FundsOfMandates.ToList(); } return(funds); } catch (InvalidOperationException inv) { //Log err throw inv; } catch (Exception ex) { //Log err throw ex; } }
public void FillMandate_ShouldAddMandate_WhenInstrumentCodeMatches() { //Arrange PortfolioVM portfolioVM = new PortfolioVM(); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000287100", Name = "Optimix Mix Fund", Value = 23456 }); FundsOfMandatesData fundsOfMandatesData = portfolioServices.GetFundOfMandates(path); int expectedMandateCount = 4; //Act int actualMandateCount = portfolioServices.FillMandate(portfolioVM, fundsOfMandatesData).Positions[0].Mandates.Count; //Assert actualMandateCount.Should().Be(expectedMandateCount); }
public void FillMandate_ShouldMatchMandates_WhenInstrumentCodeMatches() { //Arrange PortfolioVM portfolioVM = new PortfolioVM(); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000287100", Name = "Optimix Mix Fund", Value = 23456 }); List <MandateVM> expectedListOfMandates = new List <MandateVM>() { new MandateVM() { Name = "Robeco Factor Momentum Mandaat", Allocation = (decimal)0.355, Value = 8327 }, new MandateVM() { Name = "BNPP Factor Value Mandaat", Allocation = (decimal)0.383, Value = 8984 }, new MandateVM() { Name = "Robeco Factor Quality Mandaat", Allocation = (decimal)0.261, Value = 6122 }, new MandateVM() { Name = "Liquidity", Allocation = (decimal)0.001, Value = 23 }, }; FundsOfMandatesData fundsOfMandatesData = portfolioServices.GetFundOfMandates(path); //Act List <MandateVM> actualListOfMandates = portfolioServices.FillMandate(portfolioVM, fundsOfMandatesData).Positions[0].Mandates; MandateVM actualMandateVM = actualListOfMandates.Where(x => x.Name == "Robeco Factor Momentum Mandaat").FirstOrDefault(); //Assert actualListOfMandates.Should().BeEquivalentTo(expectedListOfMandates); actualMandateVM.Should().BeEquivalentTo(new MandateVM() { Name = "Robeco Factor Momentum Mandaat", Allocation = (decimal)0.355, Value = 8327 }); }
public void FillMandate_ShouldNotAddMandateForEmptyFundsOfMandateData_WhenFundsOfMandateIsEmpty() { //Arrange PortfolioVM portfolioVM = new PortfolioVM(); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000009165", Name = "Heineken", Value = 12345 }); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000287100", Name = "Optimix Mix Fund", Value = 23456 }); portfolioVM.Positions.Add(new PositionVM() { Code = "LU0035601805", Name = "DP Global Strategy L High", Value = 34567 }); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000292332", Name = "Rabobank Core Aandelen Fonds T2", Value = 45678 }); portfolioVM.Positions.Add(new PositionVM() { Code = "LU0042381250", Name = "Morgan Stanley Invest US Gr Fnd", Value = 56789 }); FundsOfMandatesData fundsOfMandatesData = new FundsOfMandatesData(); //Act portfolioVM = portfolioServices.FillMandate(portfolioVM, fundsOfMandatesData); //Assert foreach (var position in portfolioVM.Positions) { position.Mandates.Count.Should().Be(0); } }
public void CalculateMandate_ShouldMatchMandateValue_WhenInstrumentCodeMatches() { //Arrange FundsOfMandatesData fundsOfMandatesData = portfolioServices.GetFundOfMandates(path); string positioncode = "NL0000287100"; decimal positionValue = 23456; List <MandateVM> expectedMandateVM = new List <MandateVM>() { new MandateVM() { Name = "Robeco Factor Momentum Mandaat", Allocation = (decimal)0.355, Value = 8327 }, new MandateVM() { Name = "BNPP Factor Value Mandaat", Allocation = (decimal)0.383, Value = 8984 }, new MandateVM() { Name = "Robeco Factor Quality Mandaat", Allocation = (decimal)0.261, Value = 6122 }, new MandateVM() { Name = "Liquidity", Allocation = (decimal)0.001, Value = 23 }, }; //Act List <MandateVM> actualMandateVM = portfolioServices.CalculateMandate(positioncode, positionValue, fundsOfMandatesData); //Assert actualMandateVM.Should().NotBeNull(); expectedMandateVM.Count.Should().Be(actualMandateVM.Count); foreach (var mandate in actualMandateVM) { expectedMandateVM.Where(x => x.Name == mandate.Name).Select(x => x.Value).FirstOrDefault().Should().Be(mandate.Value); } }