示例#1
0
        public void Insert_Successfully()
        {
            //Arrange
            var endPoint = new EndPoint
            {
                SerialNumber         = "1AA1",
                MeterModelId         = EnumMeterModelId.NSX1P2W,
                MeterNumber          = 1,
                MeterFirmwareVersion = "A91200-1",
                SwitchState          = EnumSwitchState.Disconnected
            };

            var endPoint2 = new EndPoint
            {
                SerialNumber         = "2BB2",
                MeterModelId         = EnumMeterModelId.NSX1P2W,
                MeterNumber          = 1,
                MeterFirmwareVersion = "A91200-1",
                SwitchState          = EnumSwitchState.Disconnected
            };

            _mockRepoDao.Setup(e => e.Insert(endPoint)).Returns(true);
            _mockRepoDao.Setup(e => e.Insert(endPoint2)).Returns(true);

            //Act
            var resultadoEsperado1 = _mockRepoDao.Object.Insert(endPoint);
            var resultadoEsperado2 = _mockRepoDao.Object.Insert(endPoint2);

            var realizado1 = _sutService.Insert(endPoint);
            var realizado2 = _sutService.Insert(endPoint2);

            //Assert
            Assert.IsTrue(realizado1 == resultadoEsperado1);
            Assert.IsTrue(realizado2 == resultadoEsperado2);
        }
示例#2
0
        public void Not_Insert_More_EndPoint()
        {
            //Arrange
            var endPoint1 = new EndPoint
            {
                SerialNumber         = "1",
                MeterModelId         = EnumMeterModelId.NSX1P2W,
                MeterNumber          = 1,
                MeterFirmwareVersion = "A91200-1",
                SwitchState          = EnumSwitchState.Disconnected
            };
            var endPoint2 = new EndPoint
            {
                SerialNumber         = "1",
                MeterModelId         = EnumMeterModelId.NSX1P2W,
                MeterNumber          = 1,
                MeterFirmwareVersion = "A91200-1",
                SwitchState          = EnumSwitchState.Disconnected
            };

            _endPointDAO.Insert(endPoint1);
            _endPointService = new EndPointService(_endPointDAO);

            _mockRepo.Setup(x => x.Insert(endPoint1)).Returns(false);

            //Act
            var esperado  = _mockRepo.Object.Insert(endPoint1);
            var realizado = _endPointService.Insert(endPoint2);

            //Assert
            Assert.AreEqual(realizado, esperado);
        }