public void ParseGoodFile() { var contents = @"NBologna Bill PPungent Meat Sweats SBill BillStein"; var heroData = FormatStringAsFileContents(contents); var parser = new HeroFileParser(heroData); var heroRecords = parser.Parse(); // make sure we've got one of each record type // and the property values are what we are expecting: var nameRecord = heroRecords.OfType <NameRecord>().Single(); Assert.Equal("Bologna Bill", nameRecord.HeroName); var powerRecord = heroRecords.OfType <PowerRecord>().Single(); Assert.Equal("Pungent Meat Sweats", powerRecord.Power); var secretIdentityRecord = heroRecords.OfType <SecretIdentityRecord>().Single(); Assert.Equal("Bill", secretIdentityRecord.FirstName); Assert.Equal("BillStein", secretIdentityRecord.LastName); }
public void BadRecordTypeThrowsAnException() { var contents = @"NBologna Bill PPungent Meat Sweats SBill BillStein ~"; // <-- bad indicator here var badData = FormatStringAsFileContents(contents); var parser = new HeroFileParser(badData); Assert.Throws <UnknownRecordTypeException>(() => parser.Parse()); }