Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"env": {
"es6": true,
"es2017": true,
"mocha": true,
"node": true
},
"extends": ["eslint:recommended"],
Expand Down
7 changes: 7 additions & 0 deletions generators/generator-bot-adaptive/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"checkLeaks": true,
"exit": true,
"forbidOnly": true,
"forbidPending": true,
"recursive": true
}
10 changes: 7 additions & 3 deletions generators/generator-bot-adaptive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@
"url": "https://github.com/Microsoft/botframework-components.git"
},
"scripts": {
"lint": "eslint -c .eslintrc.json ."
"lint": "eslint -c .eslintrc.json .",
"test": "mocha"
},
"dependencies": {
"globby": "^11.0.2",
"normalize-path": "^3.0.0",
"runtypes": "~5.1.0",
"uuid": "^8.3.1",
"yeoman-generator": "^1.1.1"
"yeoman-generator": "^2.0.5"
},
"devDependencies": {
"ejs": "^3.1.6",
"eslint": "latest",
"eslint-config-prettier": "latest",
"eslint-plugin-prettier": "latest",
"prettier": "latest"
"mocha": "^8.3.2",
"prettier": "latest",
"yeoman-test": "^6.0.0"
}
}
308 changes: 308 additions & 0 deletions generators/generator-bot-adaptive/test/dotnet-functions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

const fs = require('fs');
const helpers = require('yeoman-test');
const path = require('path');
const TemplateFileReader = require('./templateFileReader');

const botName = 'DotNetFunctions';
const generatorPath = path.join(__dirname, '..', 'generators', 'app');
const integration = 'functions';
const platform = 'dotnet';
const reader = new TemplateFileReader(path.join(generatorPath, 'templates'));

describe(`generator-bot-adaptive --platform ${platform} --integration ${integration}`, function () {
let runResult;

before(async function () {
runResult = await helpers
.create(generatorPath)
.withArguments([botName])
.withOptions({ platform, integration })
.run();
});

after(function () {
if (runResult) {
runResult.restore();
}
});

it(`should create file ${botName}.sln`, function () {
const filePath = path.join(`${botName}.sln`);

const actualContent = fs.readFileSync(filePath).toString('utf8');
const projectType = 'FAE04EC0-301F-11D3-BF4B-00C04F79EFBC';

const botProjectGuidExpression = new RegExp(
`Project\\(\\"\\{${projectType}\\}\\"\\) = \\"${botName}\\", ` +
`\\"${botName}\\\\${botName}.csproj\\", ` +
`\\"\\{(.+)\\}\\"`,
'gi'
);

const botProjectGuid = botProjectGuidExpression.exec(actualContent)[1];

const solutionGuidExpression = /SolutionGuid = \{(.+)\}/gi;
const solutionGuid = solutionGuidExpression.exec(actualContent)[1];

const content = reader.getTemplateFileContent(
path.join('dotnet', 'botName.sln'),
{
botName,
botProjectGuid,
projectType,
solutionGuid,
}
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'ActivitySerializationSettings.cs'
)}`, function () {
const filePath = path.join(botName, 'ActivitySerializationSettings.cs');
const content = reader.getTemplateFileContent(
path.join('dotnet', 'functions', 'ActivitySerializationSettings.cs'),
{
botName,
}
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'appsettings.json'
)}`, function () {
const filePath = path.join(botName, 'appsettings.json');
const content = reader.getJsonFileContent(
path.join('assets', 'appsettings.json'),
{
luis: {
name: botName,
},
runtime: {
command: `func start --script-root ${path.join(
'bin',
'Debug',
'netcoreapp3.1'
)}`,
key: `adaptive-runtime-${platform}-${integration}`,
},
}
);

runResult.assertJsonFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
`${botName}.botproj`
)}`, function () {
const filePath = path.join(botName, `${botName}.botproj`);
const content = reader.getJsonFileContent(
path.join('assets', 'botName.botproj'),
{
name: botName,
}
);

runResult.assertJsonFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
`${botName}.csproj`
)}`, function () {
const filePath = path.join(botName, `${botName}.csproj`);
const content = reader.getTemplateFileContent(
path.join('dotnet', 'functions', 'botName.csproj'),
{
botName,
packageReferences: '',
sdkVersion: '4.13.2',
}
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(botName, 'host.json')}`, function () {
const filePath = path.join(botName, 'host.json');
const content = reader.getFileContent(
path.join('dotnet', 'functions', 'host.json')
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'local.settings.json'
)}`, function () {
const filePath = path.join(botName, 'local.settings.json');
const content = reader.getFileContent(
path.join('dotnet', 'functions', 'local.settings.json')
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(botName, 'Startup.cs')}`, function () {
const filePath = path.join(botName, 'Startup.cs');
const content = reader.getTemplateFileContent(
path.join('dotnet', 'functions', 'Startup.cs'),
{
botName,
settingsDirectory: 'string.Empty',
}
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'Properties',
'serviceDependencies.json'
)}`, function () {
const filePath = path.join(
botName,
'Properties',
'serviceDependencies.json'
);
const content = reader.getFileContent(
path.join('dotnet', 'functions', 'Properties', 'serviceDependencies.json')
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'Properties',
'serviceDependencies.local.json'
)}`, function () {
const filePath = path.join(
botName,
'Properties',
'serviceDependencies.local.json'
);

const content = reader.getFileContent(
path.join(
'dotnet',
'functions',
'Properties',
'serviceDependencies.local.json'
)
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'Triggers',
'MessagesTrigger.cs'
)}`, function () {
const filePath = path.join(botName, 'Triggers', 'MessagesTrigger.cs');
const content = reader.getTemplateFileContent(
path.join('dotnet', 'functions', 'Triggers', 'MessagesTrigger.cs'),
{
botName,
}
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'Triggers',
'SkillsTrigger.cs'
)}`, function () {
const filePath = path.join(botName, 'Triggers', 'SkillsTrigger.cs');
const content = reader.getTemplateFileContent(
path.join('dotnet', 'functions', 'Triggers', 'SkillsTrigger.cs'),
{
botName,
}
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'Triggers',
'StaticFilesTrigger.cs'
)}`, function () {
const filePath = path.join(botName, 'Triggers', 'StaticFilesTrigger.cs');
const content = reader.getTemplateFileContent(
path.join('dotnet', 'functions', 'Triggers', 'StaticFilesTrigger.cs'),
{
botName,
}
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'schemas',
'sdk.schema'
)}`, function () {
const filePath = path.join(botName, 'schemas', 'sdk.schema');
const content = reader.getFileContent(
path.join('assets', 'schemas', 'sdk.schema')
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'schemas',
'sdk.uischema'
)}`, function () {
const filePath = path.join(botName, 'schemas', 'sdk.uischema');
const content = reader.getFileContent(
path.join('assets', 'schemas', 'sdk.uischema')
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'schemas',
'update-schema.ps1'
)}`, function () {
const filePath = path.join(botName, 'schemas', 'update-schema.ps1');
const content = reader.getFileContent(
path.join('assets', 'schemas', 'update-schema.ps1')
);

runResult.assertFileContent(filePath, content);
});

it(`should create file ${path.join(
botName,
'schemas',
'update-schema.sh'
)}`, function () {
const filePath = path.join(botName, 'schemas', 'update-schema.sh');
const content = reader.getFileContent(
path.join('assets', 'schemas', 'update-schema.sh')
);

runResult.assertFileContent(filePath, content);
});
});
Loading