Beispiel #1
0
 /// <summary>
 /// Copies a new CPU state based on an existing CPU state
 /// </summary>
 /// <param name="cpuState">The CPU state to copy</param>
 public CPUState(ICPUState cpuState)
 {
     ProgramCounter = cpuState.ProgramCounter;
     Accumulator    = cpuState.Accumulator;
     Halt           = cpuState.Halt;
     LastOperation  = cpuState.LastOperation;
 }
Beispiel #2
0
        /// <inheritdoc/>
        public bool Equals([AllowNull] ICPUState other)
        {
            if (other == null)
            {
                return(false);
            }

            return(this.ProgramCounter == other.ProgramCounter &&
                   this.Accumulator == other.Accumulator &&
                   this.Halt == other.Halt &&
                   (
                       this.LastOperation == null && other.LastOperation == null ||
                       this.LastOperation.Equals(other.LastOperation)
                   ));
        }
        public void Constructor_GivenValidValues_SetsValuesAsExpected(
            ICPUState copyFrom,
            int expectedProgramCounter,
            int expectedAccumulator,
            bool expectedHalt,
            IOperation expectedLastOperation
            )
        {
            var sut = new CPUState(copyFrom);

            Assert.Equal(expectedProgramCounter, sut.ProgramCounter);
            Assert.Equal(expectedAccumulator, sut.Accumulator);
            Assert.Equal(expectedHalt, sut.Halt);
            Assert.Equal(expectedLastOperation, sut.LastOperation);
        }