我正在尝试使用Youtube API从特定频道中提取所有视频.我在Google Developers Console中设置了该项目并获得了API浏览器密钥.我启用了YouTube Data API v3,为了安全起见,我启用了YouTube Analytics API.
我不知道我得到了这个错误.谁能帮我.
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
],
"code": 403,
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
}
Run Code Online (Sandbox Code Playgroud)
代码我正在使用.它还没有做任何事情,只是尝试获取数据.
jQuery.getJSON('https://www.googleapis.com/youtube/v3/channels?part=UncleBens&id=UncleBens&key=AIzaSyDXD80S1mFHH2HSZFxLemkae-_Cl_nY5Xk', function(data){
console.log(data);
for(var i=0; i<data.data.items.length; i++) {
console.log(data.data.items[i].title); // title
console.log(data.data.items[i].description); // description
}
});
Run Code Online (Sandbox Code Playgroud) 我在与我查询的数据库不同的数据库中有一个用户定义的函数.有没有办法访问函数,如SQL中的完全限定名称或类似名称?我想这样做
[dbo].[EscalationManagementSystem].fncCVUnix2DateTZ(...
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误,说它找不到列"dbo"或用户定义的函数"dbo.EscalationManagemntSystem.fncCVUnix2DateTZ".我的语法错了吗?
我试图解析可能有小数的字符串.我正在使用,Int32.TryParse
但它似乎没有工作.
这是我尝试解析的函数:
private NumberStyles styles = NumberStyles.Number;
private CultureInfo culture = CultureInfo.CurrentCulture;
public int? ParseInt(string node)
{
int number;
if (Int32.TryParse(node, styles, culture.NumberFormat, out number))
{
return number;
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
这是我的单元测试失败了
[Fact]
public void TestParseIntWithDecimal()
{
string provided = "28.789";
int expected = 28;
int? actual = _parser.ParseInt(provided);
Assert.NotNull(actual);
Assert.Equal(expected, actual);
}
Run Code Online (Sandbox Code Playgroud)
当我运行我的单元测试时,null
返回ParseInt
并且我不明白为什么.我以为TryParse
可以将十进制数解析为整数.
我是嘲笑和使用Moq的新手.这是我第一次尝试模拟添加功能.我有mocks设置,它适用于读取功能,但是当我尝试对add方法进行单元测试时,它会将更改保存到db.
如何模拟add方法?
我想我必须模拟我的UnitOfWork
班级,这个班级有这个SaveChanges()
方法.我想知道如何设置模拟来拦截调用SaveChanges()
而不是保存到db.
这是我到目前为止的模拟
[SetUp]
public void SetUp()
{
addCount = 0;
IEnumerable<Platform> platformList = new List<Platform>(){
new Platform() { Id = 1, Name = "Unknown"},
new Platform() { Id =2, Name = "Amazon"},
new Platform() { Id = 3, Name = "Prime Pantry"}
};
var platformData = platformList.AsQueryable();
var mockPlatformSet = new Mock<DbSet<Platform>>();
mockPlatformSet.As<IQueryable<Platform>>().Setup(m => m.Provider).Returns(platformData.Provider);
mockPlatformSet.As<IQueryable<Platform>>().Setup(m => m.Expression).Returns(platformData.Expression);
mockPlatformSet.As<IQueryable<Platform>>().Setup(m => m.ElementType).Returns(platformData.ElementType);
mockPlatformSet.As<IQueryable<Platform>>().Setup(m => m.GetEnumerator()).Returns(platformData.GetEnumerator());
mockPlatformSet.Setup(m => m.Add(It.IsAny<Platform>())).Callback(() => addCount++);
var mockContext = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建我的第一个反应项目并尝试教程.我的webpack配置基于该示例项目,但是当我运行webpack时,我收到一个错误.这是npm-debug日志:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\daford\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'production' ]
2 info using npm@3.8.6
3 info using node@v5.10.0
4 verbose run-script [ 'preproduction', 'production', 'postproduction' ]
5 info lifecycle nestlepronourish@1.0.0~preproduction: nestlepronourish@1.0.0
6 silly lifecycle nestlepronourish@1.0.0~preproduction: no script for preproduction, continuing
7 info lifecycle nestlepronourish@1.0.0~production: nestlepronourish@1.0.0
8 verbose lifecycle nestlepronourish@1.0.0~production: unsafe-perm in lifecycle true
9 verbose lifecycle nestlepronourish@1.0.0~production: PATH: C:\Users\daford\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\Users\daford\Projects\nestlepronourish.v2\node_modules\.bin;C:\Program Files\nodejs;C:\Ruby21-x64\bin;C:\cygwin64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files …
Run Code Online (Sandbox Code Playgroud) 我有一个对象数组:
Square sq[81];
Run Code Online (Sandbox Code Playgroud)
我认为它使用默认构造函数来创建每个.
当我通过for循环来初始化每个时,它会为Square
数组中的每个对象调用析构函数.
for (int k=0; k<9; k++) {
for(int j=0; j<9; j++) {
sq[count++] = Square(k, j);
}
}
Run Code Online (Sandbox Code Playgroud)
当Square(k, j)
被调用时,它被删除的对象sq[]
,并创建一个新的?
当代码尝试验证SqlDataReader是否在列中返回空值时,与我一起处理项目的人之一不断收到错误.他运行这段代码:
if (!DB_Conn.isConnected()) DB_Conn.Connect();
using (SqlDataReader dr = DB_Conn.QueryDB(query))
{
if (dr.HasRows && !dr.IsDBNull(0))
{
maxID = dr.GetInt32(0);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当在!dr.IsDBNull(0)命令中没有数据时,会得到一个错误,它是一个无效的attemtp.
如果我运行相同的代码,但我查询不同的表,它的工作原理.
此外,我运行两个查询,他们返回预期的空值.查询是:
SELECT MAX(ID) FROM Loan;
SELECT MAX(ID) FROM InternationalSwap;
Run Code Online (Sandbox Code Playgroud)
我不认为查询对我们在一台机器而不是另一台机器上出现此错误的原因有任何影响.
当我编译我的程序时,我得到三个"未定义的引用'PrintArgv(...)'"错误.我搜索过,但找不到我收到这些错误的原因.这是我的代码:
#include "tools.hpp"
enum ARG_T {COMMAND, SWITCH, ARGUMENT};
void ReadArgs(int, char**, ofstream&);
void PrintArgv(char*, ARG_T, ofstream&);
int main(int argc, char* argv[])
{
ofstream fout;
try{
fout.open("P1Ford.txt", ios::out | ios::app);
}
catch(...)
{
//fatal("Could not open file P1Ford.txt");
cout << "Could not open file P1Ford.txt" << "\n";
return -1;
}
ReadArgs(argc, argv, fout);
fout.close();
return 0;
}
/*-----------------------------------------------------------------------------
This function takes the values passed in through the command line
then examines each one to determine if it is the command, a …
Run Code Online (Sandbox Code Playgroud) c# ×3
c++ ×2
sql-server ×2
arrays ×1
asp.net ×1
c#-4.0 ×1
destructor ×1
g++ ×1
int ×1
javascript ×1
moq ×1
node.js ×1
npm ×1
reactjs ×1
sql ×1
unit-testing ×1
webpack ×1
youtube-api ×1