public void TestCanLoadStream() { //arrange MusicContractDataMapper mapper = new MusicContractDataMapper(); //act using (Stream stream = TestHelper.GenerateStreamFromString("Artist|Title|Usages|01 March 2017|28 February 2017")) { List <string> loadErrors = new List <string>(); mapper.LoadData(stream, false, out loadErrors); stream.Close(); } //assert Assert.IsTrue(mapper.GetData().Count == 1); Assert.IsInstanceOfType(mapper.GetData(), typeof(List <MusicContract>)); Assert.AreEqual(mapper.GetData()[0].Artist, "Artist"); }
public void TestCanLoadStreamMultipleRows() { //arrange var testString = "Monkey Claw|Iron Horse|digital download, streaming|1st June 2012|" + Environment.NewLine + "Monkey Claw|Motor Mouth|digital download, streaming|1st Mar 2011|" + Environment.NewLine + "Monkey Claw|Christmas Special|streaming|25st Dec 2012|31st Dec 2012"; //despite having an incorrect date (25st Dec 2012). The parser should correctly determine this to be 25th December MusicContractDataMapper mapper = new MusicContractDataMapper(); //act using (Stream stream = TestHelper.GenerateStreamFromString(testString)) { List <string> loadErrors = new List <string>(); mapper.LoadData(stream, false, out loadErrors); stream.Close(); } //assert Assert.IsTrue(mapper.GetData().Count == 3); }
//in this test, there is no endDate field public void TestLoadStreamWithEmptyEndDate() { //arrange MusicContractDataMapper mapper = new MusicContractDataMapper(); //act using (Stream stream = TestHelper.GenerateStreamFromString("Artist|Title|Usages|01 March 2017|")) { try { List <string> loadErrors = new List <string>(); mapper.LoadData(stream, false, out loadErrors); stream.Close(); } finally { stream.Close(); } } //assert Assert.IsNull(mapper.GetData()[0].EndDate); }
public GRMRepository(DistributionPartnerDataMapper distributionPartnerDataMapper, MusicContractDataMapper musicContractDataMapper) { _musicContracts = musicContractDataMapper.GetData() ?? null; _distributionPartners = distributionPartnerDataMapper.GetData() ?? null; }