Пример #1
0
        public async Task GetSomePostsTest()
        {
            var mockJobId    = Guid.NewGuid();
            var someDate     = DateTime.Now;
            var mockPage     = 1;
            var mockPageSize = 50;
            var mockPosts    = new List <Post>
            {
                new Post {
                    Text = "What has roots as nobody sees, is taller than trees, up, up it goes, and yet never grows?"
                },
                new Post {
                    Text = "Voiceless it cries, wingless flutters, toothless bites, mouthless mutters."
                },
                new Post {
                    Text = "It cannot be seen, cannot be felt, cannot be heard, cannot be smelt. it lies behind stars and under hills, and empty holes it fills. it comes out first and follows after, ends life, kills laughter."
                }
            };
            var mockPostsCount = 6;

            var mockStorageService = new Mock <IStorageService>();
            var listWithCount      = new ListWithCount <Post> {
                Data = mockPosts, TotalCount = mockPostsCount
            };

            mockStorageService.Setup(o => o.GetPosts(mockJobId, new string[0], new string[0], someDate, someDate, mockPage - 1, mockPageSize)).Returns(Task.FromResult(listWithCount));

            var jobService = new JobService(mockStorageService.Object);
            var result     = await jobService.GetJobPosts(mockJobId, new string[0], new string[0], someDate, someDate, mockPage, mockPageSize);

            var expectedResult = (mockPosts, 3);

            Assert.AreEqual(expectedResult.Item1, result.Item1, "The backend should return posts that it received from storage");
            Assert.AreEqual(mockPostsCount, result.Item2, "The backend should return total number of posts that it received from storage");
        }
Пример #2
0
        public void Initialize()
        {
            ListWithCount <CatalogItemViewModel> listWithCount = new ListWithCount <CatalogItemViewModel>();

            foreach (VideoCatalogItem videoCatalogItem in this._videoCategory.items)
            {
                CatalogItemViewModel catalogItemViewModel = this.CreateCatalogItemViewModel(videoCatalogItem, this._knownUsers, this._knownGroups);
                listWithCount.List.Add(catalogItemViewModel);
            }
            this._catalogItemsVM.ReadData(listWithCount);
        }