public void Save_FileExists_UpdatesToValidFile() { var cassette = new Cassette(Context.Cassette1); var record = new Record("record"); var request = JObject.Parse("{\"request\":{},\"response\":{}}"); record.Write(request); cassette.Save(record); var anotherCassette = new Cassette(cassette.Path); Assert.AreEqual(3, anotherCassette.Records.Count); var record1 = anotherCassette.Records[0]; Assert.AreEqual("record1", record1.Name); Assert.AreEqual(3, record1.List.Count); var record2 = anotherCassette.Records[1]; Assert.AreEqual("record2", record2.Name); Assert.AreEqual(1, record2.List.Count); var record3 = anotherCassette.Records[2]; Assert.AreEqual("record", record3.Name); Assert.AreEqual(1, record.List.Count); }
public void Save_RewindsRecord() { var cassette = new Cassette(Context.Cassette1); var record = new Record("record"); cassette.Save(record); var record1 = cassette.Records[0]; var req1 = record1.Read(); var req2 = record1.Read(); Assert.IsNotNull(req1); Assert.IsNotNull(req2); }
public void Save_AppendsRecord() { var cassette = new Cassette(Context.Cassette1); Assert.AreEqual(2, cassette.Records.Count); var record = new Record("record"); var request = JObject.Parse("{\"request\":{},\"response\":{}}"); record.Write(request); cassette.Save(record); Assert.AreEqual(3, cassette.Records.Count); var lastRecord = cassette.Records[2]; Assert.AreEqual("record", lastRecord.Name); Assert.AreEqual(1, lastRecord.List.Count); }
public void Save_FileNotExists_CreatesValidFile() { var cassette = new Cassette(Context.CassetteNew); var record = new Record("record"); var request = JObject.Parse("{\"request\":{},\"response\":{}}"); record.Write(request); cassette.Save(record); Assert.IsTrue(File.Exists(cassette.Path)); var anotherCassette = new Cassette(cassette.Path); Assert.AreEqual(1, anotherCassette.Records.Count); record = anotherCassette.Records[0]; Assert.AreEqual("record", record.Name); Assert.AreEqual(1, record.List.Count); }