コード例 #1
0
        public void createAlertTest()
        {
            Mock <IDatabaseQueryService> mockDBService = new Mock <IDatabaseQueryService>(MockBehavior.Strict);

            mockDBService.Setup(x => x.PersistNewAlert(It.Is <DatabaseAlert>(p => p.CameraId == 1))).Returns(true);
            AlertService alertService = new AlertService(mockDBService.Object,
                                                         new CameraService(mockDBService.Object, new GraphStatisticService(mockDBService.Object), new LocationService(mockDBService.Object)),
                                                         new NotificationService(mockDBService.Object));
            AlertDetails alertDetails = new AlertDetails(dbAlerts[1]);


            Assert.That(alertService.SaveAlert(alertDetails), Is.True);
            mockDBService.Verify(m => m.PersistExistingAlert(It.IsAny <DatabaseAlert>()), Times.Never);
        }