コード例 #1
0
        public void SetUp()
        {
            _api  = Mock.Of <IVkApi>();
            _wall = Mock.Of <IWallCategory>();
            Mock.Get(_api)
            .Setup(x => x.Wall)
            .Returns(() => _wall);
            Mock.Get(_wall)
            .Setup(x => x.Post(It.IsAny <WallPostParams>()))
            .Returns(() => PostId);
            var posts = new List <Post>
            {
                CreateSomePost(),
                CreateSomePost(),
                CreateSomePost(),
                CreateSomePost(),
                CreateSomePost()
            };

            Mock.Get(_wall)
            .Setup(x => x.Get(It.IsAny <WallGetParams>(), It.IsAny <bool>()))
            .Returns(() => new WallGetObject {
                WallPosts = new ReadOnlyCollection <Post>(posts)
            });
            CreateSomePost();
            _log = Mock.Of <ILog>();
            _sut = new LetterStatsReporter(_api, _log);
        }
コード例 #2
0
        public void CountOfPostsLessThenNeed_ErrorInLog()
        {
            _sut = new LetterStatsReporter(_api, _log, 10);

            _sut.Execute(Id);

            Mock.Get(_wall)
            .Verify(x => x.Get(It.IsAny <WallGetParams>(), It.IsAny <bool>()), Times.Once);
            Mock.Get(_wall)
            .Verify(x => x.Post(It.IsAny <WallPostParams>()), Times.Never);
            Mock.Get(_log)
            .Verify(x => x.Error(It.IsAny <string>()), Times.Once);
        }