public void SquareNumberInCpu128ShouldDrawErrorMessageWhenValueIsGreaterThanMaxValue()
 {
     var cpu = new Cpu128(4);
     var motherboardMock = new Mock<IMotherboard>();
     motherboardMock.Setup(x => x.LoadRamValue()).Returns(Cpu128.MaxValue + 1);
     cpu.AttachTo(motherboardMock.Object);
     cpu.SquareNumber();
     motherboardMock.Verify(x => x.DrawOnVideoCard(
         It.Is<string>(param => param == Cpu.NumberTooHighMessage)));
 }
        public void SquareNumberInCpu128ShouldDrawErrorMessageWhenValueIsGreaterThanMaxValue()
        {
            var cpu             = new Cpu128(4);
            var motherboardMock = new Mock <IMotherboard>();

            motherboardMock.Setup(x => x.LoadRamValue()).Returns(Cpu128.MaxValue + 1);
            cpu.AttachTo(motherboardMock.Object);
            cpu.SquareNumber();
            motherboardMock.Verify(x => x.DrawOnVideoCard(
                                       It.Is <string>(param => param == Cpu.NumberTooHighMessage)));
        }
示例#3
0
 public void TestMethod3()
 {
     var mockedMother = new Mock<IMotherboard>();
     Cpu processor = new Cpu128(2);
     string result = string.Empty;
     mockedMother.Setup(x => x.DrawOnVideoCard(It.IsAny<string>())).Callback<string>(txt => result = txt);
     mockedMother.Setup(x => x.LoadRamValue()).Returns(2001);
     processor.AttachTo(mockedMother.Object);
     processor.SquareNumber();
     Assert.AreEqual(processor.MessageForHighNumber, result);
 }
示例#4
0
 public void TestMethod1()
 {
     var mockedMother = new Mock<IMotherboard>();
     Cpu processor = new Cpu128(2);
     string result = string.Empty;
     mockedMother.Setup(x => x.DrawOnVideoCard(It.IsAny<string>())).Callback<string>(txt => result = txt);
     mockedMother.Setup(x => x.LoadRamValue()).Returns(2000);
     processor.AttachTo(mockedMother.Object);
     processor.SquareNumber();
     Assert.IsTrue(result.Contains("4000000"));
 }
示例#5
0
        public void TestMethod222()
        {
            var    mockedMother = new Mock <IMotherboard>();
            Cpu    processor    = new Cpu128(2);
            string result       = string.Empty;

            mockedMother.Setup(x => x.DrawOnVideoCard(It.IsAny <string>())).Callback <string>(txt => result = txt);
            mockedMother.Setup(x => x.LoadRamValue()).Returns(0);
            processor.AttachTo(mockedMother.Object);
            processor.SquareNumber();
            Assert.AreEqual(true, result.Contains("0"));
        }
示例#6
0
        public void TestRandomToHaveMinimalValue()
        {
            var mockedMother = new Mock<IMotherboard>();
            int value = int.MaxValue;

            mockedMother.Setup(x => x.SaveRamValue(It.IsAny<int>())).Callback<int>(calcNum => value = Math.Min(value, calcNum));

            Cpu processor = new Cpu128(2);
            processor.AttachTo(mockedMother.Object);
            int expectedResult = 1;
            for (int i = 0; i < 1000; i++)
            {
                processor.Rand(1, 10);
            }

            Assert.AreEqual(expectedResult, value);
        }
示例#7
0
        public void TestRandomToHaveMaximalValue()
        {
            var mockedMother = new Mock <IMotherboard>();
            int value        = int.MinValue;

            mockedMother.Setup(x => x.SaveRamValue(It.IsAny <int>())).Callback <int>(calcNum => value = Math.Max(value, calcNum));

            Cpu processor = new Cpu128(2);

            processor.AttachTo(mockedMother.Object);
            int expectedResult = 10;

            for (int i = 0; i < 1000; i++)
            {
                processor.Rand(1, 10);
            }

            Assert.AreEqual(expectedResult, value);
        }