예제 #1
0
        public void GetAllPinnedNewsByCategory_PinnedNewsIsInCategory_NotEmptyList()
        {
            var categoryId1 = Guid.NewGuid().ToString();
            var categoryId2 = Guid.NewGuid().ToString();
            var categoryId3 = Guid.NewGuid().ToString();
            var listObjects = new List <PinNews>
            {
                new PinNews()
                {
                    CategoryId = categoryId1, NewsItemId = Guid.NewGuid().ToString()
                },
                new PinNews()
                {
                    CategoryId = categoryId2, NewsItemId = Guid.NewGuid().ToString()
                }
            };

            Mock <IRepository <PinNews> > mock = new Mock <IRepository <PinNews> >();

            mock.Setup(m => m.GetMany(pn => pn.CategoryId == categoryId1))
            .Returns(listObjects.Where(pn => pn.CategoryId == categoryId1));
            mock.Setup(m => m.GetMany(pn => pn.CategoryId == categoryId2))
            .Returns(listObjects.Where(pn => pn.CategoryId == categoryId2));
            mock.Setup(m => m.GetMany(pn => pn.CategoryId == categoryId3))
            .Returns(listObjects.Where(pn => pn.CategoryId == categoryId3));

            PinNewsService service = new PinNewsService(mock.Object);

            var result = service.GetAllPinnedNewsByCategory(categoryId1);

            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Count() == 1);
        }
예제 #2
0
 public MainModel(
     INewsService newsService,
     IFileDownloadService downloadService,
     ISettingsService settingsService,
     IMenuService menuService,
     IUsersService usersService,
     PinNewsService pinNewsService,
     IAppFileProvider fileProvider,
     IPermissionService permissionService,
     IPictureService pictureService)
 {
     _newsService       = newsService;
     _downloadService   = downloadService;
     _settingsService   = settingsService;
     _menuService       = menuService;
     _usersService      = usersService;
     _pinNewsService    = pinNewsService;
     _fileProvider      = fileProvider;
     _permissionService = permissionService;
     _pictureService    = pictureService;
 }