Esempio n. 1
0
        public void TestRepoShouldNotBeCalledIfWatchIdIsNullOrEmpty(string watchId)
        {
            //Given
            var mockRepo = new Mock <IWatchRepository>();
            var service  = new WatchService(mockRepo.Object);

            //When
            mockRepo.Setup(mr => mr.ReadAllMachineSubscriptionsByWatch(It.IsAny <string>())).Returns(It.IsAny <List <AlarmSystem.Core.Entity.DB.MachineWatch> >());

            //Then
            Assert.Throws <InvalidDataException>(() => service.GetMachineSubscriptionsFromWatch(watchId));
            mockRepo.Verify(mr => mr.ReadAllMachineSubscriptionsByWatch(It.IsAny <string>()), Times.Never);
        }
Esempio n. 2
0
        public void TestRepoShouldBeCalledOnceIfWatchIdIsNotEmptyOrNull()
        {
            //Given
            var mockRepo = new Mock <IWatchRepository>();
            var service  = new WatchService(mockRepo.Object);
            var watchId  = "watch-id-1";

            //When
            mockRepo.Setup(mr => mr.ReadAllMachineSubscriptionsByWatch(It.IsAny <string>())).Returns(It.IsAny <List <AlarmSystem.Core.Entity.DB.MachineWatch> >());

            service.GetMachineSubscriptionsFromWatch(watchId);

            //Then
            mockRepo.Verify(mr => mr.ReadAllMachineSubscriptionsByWatch(It.IsAny <string>()), Times.Once);
        }