Esempio n. 1
0
        public void GetLogs_LogsNotExist_ReturnsNullList()
        {
            Mock<IRepository<Log>> repository = new Mock<IRepository<Log>>();
            repository.SetupSequence(o => o.GetAll()).Returns(null);

            LoggerService service = new LoggerService(repository.Object);
            IList<Log> logs = service.GetLogs();
            Assert.IsNull(logs);
        }
Esempio n. 2
0
        public void GetLogs_LogsExist_ReturnsList()
        {
            IList<Log> logs = new List<Log>()
            {
                new Log(),
                new Log(),
                new Log(),
                new Log()
            };

            Mock<IRepository<Log>> Repository = new Mock<IRepository<Log>>();
            Repository.Setup(o => o.GetAll()).Returns(logs);

            LoggerService Service = new LoggerService(Repository.Object);
            IList<Log> RetrievedLogs = Service.GetLogs();
            CollectionAssert.AreEqual(logs, RetrievedLogs);
        }