public void Cache_User() { var apiObject = new InternalVkApiObject() { Id = 123, Type = InternalVkObjectType.User }; A.CallTo(() => vkClient.GetUsers(A <InternalVkApiUserGetRequestParams> .Ignored)) .Returns(new[] { A.Dummy <InternalVkApiUser>() }); usernameProvider.GetUsernameForObject(apiObject); usernameProvider.GetUsernameForObject(apiObject); A.CallTo(() => vkClient.GetUsers(A <InternalVkApiUserGetRequestParams> .Ignored)) .MustHaveHappenedOnceExactly(); }
public void Execute(RequestProcessorProcessArgs <StatRequestParameters> args) { var screenName = args.RequestParams.ScreenName; var printer = args.UserMessagePrinter; var vkApiObject = screenNamesToVkApiObjectsCache.GetOrAdd(screenName); if (vkApiObject?.Id == null) { printer.NoUserOrGroup(screenName); return; } var username = usernameProvider.GetUsernameForObject(vkApiObject); var wallGetObject = vkClient.WallGet(new InternalVkApiWallGetRequestParams { OwnerId = vkApiObject.Id.Value, Count = settings.VkWallGetPostsCountParameter }); var stats = statsBuilders.Select(builder => builder.Build(new StatsBuilderBuildArgs { WallGetObject = wallGetObject, Username = username }) ); var statsMessage = string.Join(Environment.NewLine, stats); printer.UnderlyingPrinter.Print(statsMessage); printer.PostingStatsMessageToGroupWithId(settings.VkGroupOwnerIdForWallPost); vkClient.WallPost(new InternalVkApiWallPostRequestParams { OwnerId = settings.VkGroupOwnerIdForWallPost, Message = statsMessage }); }