public void SetNameIsNotCalledAfterFirstDataBlock() { // --- Arrange var vm = new SpectrumTapeDeviceTestMachine(); var saveProvider = new FakeSaveToTapeProvider(); var td = new TapeDevice(saveProvider); td.OnAttachedToVm(vm); var testData = new byte[] { 0x00, 0x00, 0x42, 0x6F, 0x72, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x4F, 0x00, 0x6F, 0x80, 0x4F, 0x00, 0xC3 }; EmitFullDataBlock(vm, td, testData); var before = saveProvider.SuggestedName; saveProvider.Reset(); // --- Act EmitFullDataBlock(vm, td, testData); // --- Assert before.ShouldBe("Border"); saveProvider.SuggestedName.ShouldBeNull(); }
public void CreateTapeFileIsInvokedWhenEnteringSaveMode() { // --- Arrange var vm = new SpectrumTapeDeviceTestMachine(); var saveProvider = new FakeSaveToTapeProvider(); var td = new TapeDevice(saveProvider); td.OnAttachedToVm(vm); vm.Cpu.Registers.PC = td.SaveBytesRoutineAddress; // --- Act td.SetTapeMode(); // --- Assert td.CurrentMode.ShouldBe(TapeOperationMode.Save); saveProvider.CreateTapeFileInvoked.ShouldBeTrue(); }
public void SaveTzxBlockIsCalledWhenCompletingDataBlock() { // --- Arrange var vm = new SpectrumTapeDeviceTestMachine(); var saveProvider = new FakeSaveToTapeProvider(); var td = new TapeDevice(saveProvider); td.OnAttachedToVm(vm); var testData = new byte[] { 0x90, 0x02, 0x05, 0xAA, 0xFF, 0x63 }; // --- Act EmitFullDataBlock(vm, td, testData); // --- Assert td.CurrentMode.ShouldBe(TapeOperationMode.Save); td.SavePhase.ShouldBe(SavePhase.None); saveProvider.SaveTzxBlockInvoked.ShouldBeTrue(); }
public void SetNameIsNotCalledWithInvalidHeader() { // --- Arrange var vm = new SpectrumTapeDeviceTestMachine(); var saveProvider = new FakeSaveToTapeProvider(); var td = new TapeDevice(saveProvider); td.OnAttachedToVm(vm); var testData = new byte[] { 0x42, 0x6F, 0x72, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20 }; // --- Act EmitFullDataBlock(vm, td, testData); // --- Assert td.CurrentMode.ShouldBe(TapeOperationMode.Save); td.SavePhase.ShouldBe(SavePhase.None); saveProvider.SuggestedName.ShouldBeNull(); }
public void FinalizeTapeFileIsInvokedWhenLeavingSaveMode() { // --- Arrange var vm = new SpectrumTapeDeviceTestMachine(); var saveProvider = new FakeSaveToTapeProvider(); var td = new TapeDevice(saveProvider); td.OnAttachedToVm(vm); vm.Cpu.Registers.PC = td.SaveBytesRoutineAddress; td.SetTapeMode(); var before = td.CurrentMode; // --- Act var debugCpu = vm.Cpu as IZ80CpuTestSupport; debugCpu.SetTacts(2 * TapeDevice.SAVE_STOP_SILENCE); td.SetTapeMode(); // --- Assert before.ShouldBe(TapeOperationMode.Save); td.CurrentMode.ShouldBe(TapeOperationMode.Passive); saveProvider.FinalizeTapeFileInvoked.ShouldBeTrue(); }