public void Update_WithNullData_ThrowsException() { var bitAggregate = new BitAggregate(MockBitFactory.CreateEmptyMockBits(8)); Action action = () => { bitAggregate.Update(null); }; Assert.Throws <ArgumentNullException>(action); }
public void Update_WithInvalidData_ThrowsException(params int[] updateValues) { var bitAggregate = new BitAggregate(MockBitFactory.CreateEmptyMockBits(8)); Action action = () => { bitAggregate.Update(updateValues); }; Assert.Throws <ArgumentOutOfRangeException>(action); }
public void Constructor_SameBitInput_ThrowsException(int bitCount, params int[] samePositions) { var bits = MockBitFactory.CreateSameMockBits(bitCount, samePositions); Action action = () => { new BitAggregate(bits); }; Assert.Throws <ArgumentOutOfRangeException>(action); }
public void Read_InitializedObject_ReturnsExpectedValue(params int[] initValues) { var bits = MockBitFactory.CreateMockBits(initValues); var bitAggregate = new BitAggregate(bits); var bitValues = bitAggregate.Read(); Assert.Equal(bitValues, initValues); }
public void Update_WithValidData_MakesExpectedChanges(params int[] updateValues) { var bitAggregate = new BitAggregate(MockBitFactory.CreateEmptyMockBits(8)); bitAggregate.Update(updateValues); var bitValues = bitAggregate.Read(); Assert.Equal(bitValues, updateValues); }
public void Clear_ZeroesAllBits() { var bitAggregate = new BitAggregate(MockBitFactory.CreateMockBits(0, 1, 0, 0, 1, 1, 0, 0)); bitAggregate.Clear(); var bitValues = bitAggregate.Read(); Assert.Equal(bitValues, ListFactory.CreateList(0, 0, 0, 0, 0, 0, 0, 0)); }
public void ShiftRight_PerformsAsExpected(int lowestBitValue) { var bitAggregate = new BitAggregate(MockBitFactory.CreateMockBits(lowestBitValue, 0, 1, 0, 1, 0, 1, 0)); int carryFlagValue = bitAggregate.ShiftRight(); var bitValues = bitAggregate.Read(); Assert.Equal(bitValues, ListFactory.CreateList(0, 1, 0, 1, 0, 1, 0, 0)); Assert.Equal(lowestBitValue, carryFlagValue); }
public void Constructor_WithIncorrectNumberOfBits_ThrowsException(int bitCount) { Action action = () => { new Byte(MockBitFactory.CreateEmptyMockBits(bitCount)); }; Assert.Throws <ArgumentOutOfRangeException>(action); }
public void Constructor_WithExpectedNumberOfBits_ReturnsByte() { var b = new Byte(MockBitFactory.CreateEmptyMockBits(ByteMetadata.LengthInBits)); Assert.NotNull(b); }
public static IBitRepository <MemoryBitId> CreateMemoryBitRepository(int memoryCellCount, int bitStateCount = Bit.MinBitStateCount) { var memoryBitRepository = new Mock <IBitRepository <MemoryBitId> >(); memoryBitRepository.Setup(x => x.GetBit(It.IsAny <MemoryBitId>())).Returns <MemoryBitId>(bitId => { return((0 <= bitId.CellNumber && bitId.CellNumber < memoryCellCount) ? MockBitFactory.CreateMockBit(bitStateCount) : throw new ArgumentOutOfRangeException()); }); return(memoryBitRepository.Object); }
public void Constructor_EmptyInput_ThrowsException() { Action action = () => { new BitAggregate(MockBitFactory.CreateMockBits()); }; Assert.Throws <ArgumentOutOfRangeException>(action); }
public void Constructor_ValidInput_ReturnsBitAggregate() { var bitAggregate = new BitAggregate(MockBitFactory.CreateMockBits(0, 0, 0, 0, 0, 0, 0, 0)); Assert.NotNull(bitAggregate); }