public void AssembleInstruction_Returns_Single_Line() { // arrange var instruction = new ComputeInstruction(ComputeDestinationType.None, "D+1", ComputeJumpType.None); var computeBitsAssembler = Substitute.For <IHackComputeBitsAssembler>(); computeBitsAssembler.AssembleComputeBits(Arg.Any <string>()).Returns("0000000"); var assembler = new HackComputeInstructionAssembler(computeBitsAssembler); // act string[] result = assembler.AssembleInstruction(instruction); // assert Assert.AreEqual(1, result.Length); }
public void AssembleInstruction_Returns_Correct_Jump_Bits(ComputeJumpType jumpType, string expected) { // arrange var instruction = new ComputeInstruction(ComputeDestinationType.None, "D&A", jumpType); var computeBitsAssembler = Substitute.For<IHackComputeBitsAssembler>(); computeBitsAssembler.AssembleComputeBits(Arg.Any<string>()).Returns("0000000"); var assembler = new HackComputeInstructionAssembler(computeBitsAssembler); // act string[] result = assembler.AssembleInstruction(instruction); string line = result[0]; // assert Assert.AreEqual(expected, line); }
public void AssembleInstruction_Returns_16_Bit_Line() { // arrange var instruction = new ComputeInstruction(ComputeDestinationType.None, "D+1", ComputeJumpType.None); var computeBitsAssembler = Substitute.For<IHackComputeBitsAssembler>(); computeBitsAssembler.AssembleComputeBits(Arg.Any<string>()).Returns("0000000"); var assembler = new HackComputeInstructionAssembler(computeBitsAssembler); // act string[] result = assembler.AssembleInstruction(instruction); string line = result[0]; // assert Assert.AreEqual(16, line.Length); }
public void AssembleInstruction_Returns_Correct_Dest_Bits(ComputeDestinationType destinationType, string expected) { // arrange var instruction = new ComputeInstruction(destinationType, "D&A", ComputeJumpType.None); var computeBitsAssembler = Substitute.For <IHackComputeBitsAssembler>(); computeBitsAssembler.AssembleComputeBits(Arg.Any <string>()).Returns("0000000"); var assembler = new HackComputeInstructionAssembler(computeBitsAssembler); // act string[] result = assembler.AssembleInstruction(instruction); string line = result[0]; // assert Assert.AreEqual(expected, line); }
public void AssembleInstruction_Returns_Line_Starts_With_Three_Digits() { // arrange var instruction = new ComputeInstruction(ComputeDestinationType.None, "D+1", ComputeJumpType.None); var computeBitsAssembler = Substitute.For <IHackComputeBitsAssembler>(); computeBitsAssembler.AssembleComputeBits(Arg.Any <string>()).Returns("0000000"); var assembler = new HackComputeInstructionAssembler(computeBitsAssembler); // act string[] result = assembler.AssembleInstruction(instruction); string line = result[0]; // assert Assert.AreEqual("111", line.Substring(0, 3)); }
public void AssembleInstruction_Returns_Line_Starts_With_Three_Digits() { // arrange var instruction = new ComputeInstruction(ComputeDestinationType.None, "D+1", ComputeJumpType.None); var computeBitsAssembler = Substitute.For<IHackComputeBitsAssembler>(); computeBitsAssembler.AssembleComputeBits(Arg.Any<string>()).Returns("0000000"); var assembler = new HackComputeInstructionAssembler(computeBitsAssembler); // act string[] result = assembler.AssembleInstruction(instruction); string line = result[0]; // assert Assert.AreEqual("111", line.Substring(0, 3)); }