Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ The command above uses the [complexity-report-html](https://github.com/igneel64/
- Yeoman: [Yeoman Github repository](https://github.com/yeoman)
- Microsoft: [Node.js debugging in VS Code](https://code.visualstudio.com/docs/nodejs/nodejs-debugging)
- Microsoft: [Unit testing C# in .NET Core using dotnet test and xUnit](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-dotnet-test)
- xUnit.net: [xUnit Github repository](https://xunit.github.io)
- xUnit.net: [xUnit](https://xunit.net/)
6 changes: 3 additions & 3 deletions app/application-project-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ module.exports = class ApplicationProjectGenerator {
}

_generateApplicationProject() {
this.dotnetCli.createNewApplication(this.configuration.solutionDirectory, this.configuration.applicationProjectName);
this.dotnetCli.createNewApplication(this.configuration.applicationProjectDirectory, this.configuration.applicationProjectName);
}

_addClassLibraryReferenceToApplicationProject() {
this.dotnetCli.addProjectReference(this.configuration.solutionDirectory,
this.dotnetCli.addProjectReference(
this.configuration.applicationProjectPath,
this.configuration.libraryProjectPath);
}

_addApplicationProjectToSolution() {
this.dotnetCli.addProjectToSolution(this.configuration.solutionDirectory, this.configuration.applicationProjectPath);
this.dotnetCli.addProjectToSolution(this.configuration.solutionPath, this.configuration.applicationProjectPath);
}

generate() {
Expand Down
4 changes: 2 additions & 2 deletions app/class-library-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ module.exports = class ClassLibraryGenerator {
}

_generateClassLibrary() {
this.dotnetCli.createNewClassLibrary(this.configuration.solutionDirectory, this.configuration.libraryProjectName);
this.dotnetCli.createNewClassLibrary(this.configuration.libraryProjectDirectory, this.configuration.libraryProjectName);
}

_addClassLibraryToSolution() {
this.dotnetCli.addProjectToSolution(this.configuration.solutionDirectory, this.configuration.libraryProjectPath);
this.dotnetCli.addProjectToSolution(this.configuration.solutionPath, this.configuration.libraryProjectPath);
}

generate() {
Expand Down
35 changes: 23 additions & 12 deletions app/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = class Configuration {

this.currentDirectory = ".";

this.solutionExtension = '.sln';
this.projectExtension = '.csproj';
this.librarySuffix = '.Lib';
this.testSuffix = '.Tests';
Expand All @@ -32,28 +33,38 @@ module.exports = class Configuration {
} else {
this.disableSeparateSolutionDir();
}

this.libraryProjectName = this.solutionName + this.librarySuffix;
const libraryProjectFileName = this.libraryProjectName + this.projectExtension;
this.libraryProjectPath = path.join(this.libraryProjectName, libraryProjectFileName);

this.testProjectName = this.libraryProjectName + this.testSuffix;
const testProjectFileName = this.testProjectName + this.projectExtension;
this.testProjectPath = path.join(this.testProjectName, testProjectFileName);

this.applicationProjectName = this.solutionName + this.applicationSuffix;
const applicationProjectFileName = this.applicationProjectName + this.projectExtension;
this.applicationProjectPath = path.join(this.applicationProjectName, applicationProjectFileName);
}

enableSeparateSolutionDir() {
this.isSeparateSolutionDirEnabled = true;
this.solutionDirectory = this.solutionName;
this.updateSolutionDirDependentConfig();
}

disableSeparateSolutionDir() {
this.isSeparateSolutionDirEnabled = false;
this.solutionDirectory = this.currentDirectory;
this.updateSolutionDirDependentConfig();
}

updateSolutionDirDependentConfig() {
this.solutionPath = path.join(this.solutionDirectory, this.solutionName);
this.solutionPath += this.solutionExtension;

this.libraryProjectName = this.solutionName + this.librarySuffix;
this.libraryProjectDirectory = path.join(this.solutionDirectory, this.libraryProjectName);
const libraryProjectFileName = this.libraryProjectName + this.projectExtension;
this.libraryProjectPath = path.join(this.libraryProjectDirectory, libraryProjectFileName);

this.testProjectName = this.libraryProjectName + this.testSuffix;
this.testProjectDirectory = path.join(this.solutionDirectory, this.testProjectName);
const testProjectFileName = this.testProjectName + this.projectExtension;
this.testProjectPath = path.join(this.testProjectDirectory, testProjectFileName);

this.applicationProjectName = this.solutionName + this.applicationSuffix;
this.applicationProjectDirectory = path.join(this.solutionDirectory, this.applicationProjectName);
const applicationProjectFileName = this.applicationProjectName + this.projectExtension;
this.applicationProjectPath = path.join(this.applicationProjectDirectory, applicationProjectFileName);
}

selectMitLicense() {
Expand Down
19 changes: 7 additions & 12 deletions app/dotnet-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,22 @@ module.exports = class DotnetCli {
}

createNewClassLibrary(directory, libraryProjectName) {
this.runInDirectoryAndReturnAfterwards(directory,
() => this.runDotnetWithArgumentsOrThrow('new', 'classlib', '--language', 'C#', '--name', libraryProjectName));
this.runDotnetWithArgumentsOrThrow('new', 'classlib', '--output', directory, '--language', 'C#', '--name', libraryProjectName);
}

addProjectToSolution(solutionName, projectPath) {
this.runInDirectoryAndReturnAfterwards(solutionName,
() => this.runDotnetWithArgumentsOrThrow('sln', 'add', projectPath));
addProjectToSolution(solutionPath, projectPath) {
this.runDotnetWithArgumentsOrThrow('sln', solutionPath, 'add', projectPath);
}

createNewTestProject(directory, testProjectName) {
this.runInDirectoryAndReturnAfterwards(directory,
() => this.runDotnetWithArgumentsOrThrow('new', 'xunit', '--name', testProjectName));
this.runDotnetWithArgumentsOrThrow('new', 'xunit', '--output', directory, '--name', testProjectName);
}

addProjectReference(directory, targetProjectPath, referenceProjectPath) {
this.runInDirectoryAndReturnAfterwards(directory,
() => this.runDotnetWithArgumentsOrThrow('add', targetProjectPath, 'reference', referenceProjectPath));
addProjectReference(targetProjectPath, referenceProjectPath) {
this.runDotnetWithArgumentsOrThrow('add', targetProjectPath, 'reference', referenceProjectPath);
}

createNewApplication(directory, applicationProjectName) {
this.runInDirectoryAndReturnAfterwards(directory,
() => this.runDotnetWithArgumentsOrThrow('new', 'console', '--language', 'C#', '--name', applicationProjectName));
this.runDotnetWithArgumentsOrThrow('new', 'console', '--output', directory, '--language', 'C#', '--name', applicationProjectName);
}
}
6 changes: 3 additions & 3 deletions app/test-project-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ module.exports = class TestProjectGenerator {
}

_generateTestProject() {
this.dotnetCli.createNewTestProject(this.configuration.solutionDirectory, this.configuration.testProjectName);
this.dotnetCli.createNewTestProject(this.configuration.testProjectDirectory, this.configuration.testProjectName);
}

_addClassLibraryReferenceToTestProject() {
this.dotnetCli.addProjectReference(this.configuration.solutionDirectory,
this.dotnetCli.addProjectReference(
this.configuration.testProjectPath,
this.configuration.libraryProjectPath);
}

_addTestProjectToSolution() {
this.dotnetCli.addProjectToSolution(this.configuration.solutionDirectory, this.configuration.testProjectPath);
this.dotnetCli.addProjectToSolution(this.configuration.solutionPath, this.configuration.testProjectPath);
}

generate() {
Expand Down
6 changes: 4 additions & 2 deletions test/fast/application-generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('ApplicationProjectGenerator',
function () {
applicationProjectGenerator.generate();

dotnetCliStub.addProjectReference.should.have.been.calledOnceWithExactly(expectedSolutionName,
dotnetCliStub.addProjectReference.should.have.been.calledOnceWithExactly(
expectedApplicationProjectPath,
expectedLibraryProjectPath);
});
Expand All @@ -56,6 +56,7 @@ describe('ApplicationProjectGenerator',
function () {
applicationProjectGenerator.generate();

// TODO: Fix: first parameter should be solutionPath
dotnetCliStub.addProjectToSolution.should.have.been.calledOnceWithExactly(expectedSolutionName, expectedApplicationProjectPath);
});
});
Expand All @@ -79,7 +80,7 @@ describe('ApplicationProjectGenerator',
function () {
applicationProjectGenerator.generate();

dotnetCliStub.addProjectReference.should.have.been.calledOnceWithExactly(currentDirectory,
dotnetCliStub.addProjectReference.should.have.been.calledOnceWithExactly(
expectedApplicationProjectPath,
expectedLibraryProjectPath);
});
Expand All @@ -88,6 +89,7 @@ describe('ApplicationProjectGenerator',
function () {
applicationProjectGenerator.generate();

// TODO: Fix: first parameter should be solutionPath
dotnetCliStub.addProjectToSolution.should.have.been.calledOnceWithExactly(currentDirectory, expectedApplicationProjectPath);
});
});
Expand Down
2 changes: 2 additions & 0 deletions test/fast/class-library-generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('ClassLibraryGenerator',

classLibraryGenerator.generate();

// TODO: Fix: first parameter should be solutionPath
dotnetCliStub.addProjectToSolution.should.have.been.calledOnceWithExactly(expectedSolutionName, expectedProjectPath);
});
});
Expand Down Expand Up @@ -72,6 +73,7 @@ describe('ClassLibraryGenerator',

classLibraryGenerator.generate();

// TODO: Fix: first parameter should be solutionPath
dotnetCliStub.addProjectToSolution.should.have.been.calledOnceWithExactly(currentDirectory, expectedProjectPath);
});
});
Expand Down
6 changes: 4 additions & 2 deletions test/fast/test-project-generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('TestProjectGenerator',
function () {
testProjectGenerator.generate();

dotnetCliStub.addProjectReference.should.have.been.calledOnceWithExactly(expectedSolutionName,
dotnetCliStub.addProjectReference.should.have.been.calledOnceWithExactly(
expectedTestProjectPath,
expectedLibraryProjectPath);
});
Expand All @@ -56,6 +56,7 @@ describe('TestProjectGenerator',
function () {
testProjectGenerator.generate();

// TODO: Fix: first parameter should be solutionPath
dotnetCliStub.addProjectToSolution.should.have.been.calledOnceWithExactly(expectedSolutionName, expectedTestProjectPath);
});
});
Expand All @@ -80,14 +81,15 @@ describe('TestProjectGenerator',
function () {
testProjectGenerator.generate();

dotnetCliStub.addProjectReference.should.have.been.calledOnceWithExactly(currentDirectory, expectedTestProjectPath,
dotnetCliStub.addProjectReference.should.have.been.calledOnceWithExactly(expectedTestProjectPath,
expectedLibraryProjectPath);
});

it('should add the correct test project to the correct solution',
function () {
testProjectGenerator.generate();

// TODO: Fix: first parameter should be solutionPath
dotnetCliStub.addProjectToSolution.should.have.been.calledOnceWithExactly(currentDirectory, expectedTestProjectPath);
});
});
Expand Down