-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic comments handling #311
Changes from 8 commits
e3cd0e8
2e72a8d
1441182
22d76a0
1a2f435
42aee8e
1d7514b
00c3c52
c607716
d5cf76c
8b4bf7f
bb42048
c36530c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="Table.cs" company="PicklesDoc"> | ||
// Copyright 2011 Jeffrey Cameron | ||
// Copyright 2012-present PicklesDoc team and community contributors | ||
// | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace PicklesDoc.Pickles.ObjectModel | ||
{ | ||
public enum CommentType | ||
{ | ||
Normal, | ||
StepComment, | ||
AfterLastStepComment | ||
} | ||
|
||
public class Comment | ||
{ | ||
public Comment() | ||
{ | ||
// Set default | ||
this.Type = CommentType.Normal; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line contains whitespace, please remove it |
||
public string Text { get; set; } | ||
|
||
public Location Location { get; set; } | ||
|
||
public CommentType Type { get; set; } | ||
|
||
public Step Step { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="Table.cs" company="PicklesDoc"> | ||
// Copyright 2011 Jeffrey Cameron | ||
// Copyright 2012-present PicklesDoc team and community contributors | ||
// | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the unused using. |
||
|
||
namespace PicklesDoc.Pickles.ObjectModel | ||
{ | ||
public class Location | ||
{ | ||
public int Column { get; set; } | ||
|
||
public int Line { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,8 @@ public Scenario() | |
|
||
public Feature Feature { get; set; } | ||
|
||
public Location Location { get; set; } | ||
|
||
#endregion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not strictly your code, but do me a favour and remove the |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,17 @@ | |
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace PicklesDoc.Pickles.ObjectModel | ||
{ | ||
public class Step | ||
{ | ||
public Step() | ||
{ | ||
this.Comments = new List<Comment>(); | ||
} | ||
|
||
public Keyword Keyword { get; set; } | ||
|
||
public string NativeKeyword { get; set; } | ||
|
@@ -31,5 +38,9 @@ public class Step | |
public Table TableArgument { get; set; } | ||
|
||
public string DocStringArgument { get; set; } | ||
|
||
public Location Location { get; set; } | ||
|
||
public List<Comment> Comments { get; set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the extra whitespace at the end of the |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Autofac; | ||
using ClosedXML.Excel; | ||
using NFluent; | ||
|
@@ -47,5 +49,107 @@ public void ThenStepAddedSuccessfully() | |
Check.That(worksheet.Cell("D5").Value).IsEqualTo(step.Name); | ||
} | ||
} | ||
|
||
[Test] | ||
public void ThenStepCommentsAreAddedSuccesfully() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Successfully is spelled with three s in total :-) |
||
{ | ||
var excelStepFormatter = Container.Resolve<ExcelStepFormatter>(); | ||
var step = new Step | ||
{ | ||
NativeKeyword = "Given", | ||
Name = "I have some precondition", | ||
Comments = new List<Comment>() | ||
{ | ||
new Comment() | ||
{ | ||
Text = "# A comment", | ||
Type = CommentType.StepComment | ||
} | ||
} | ||
}; | ||
|
||
using (var workbook = new XLWorkbook()) | ||
{ | ||
IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); | ||
int row = 5; | ||
excelStepFormatter.Format(worksheet, step, ref row); | ||
|
||
Check.That(worksheet.Cell("C5").Value).IsEqualTo(step.Comments.First().Text); | ||
Check.That(worksheet.Cell("C6").Value).IsEqualTo(step.NativeKeyword); | ||
Check.That(worksheet.Cell("D6").Value).IsEqualTo(step.Name); | ||
} | ||
} | ||
|
||
[Test] | ||
public void ThenMultilineStepCommentsAreAddedSuccesfully() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Successfully is spelled with three s in total :-) |
||
{ | ||
var excelStepFormatter = Container.Resolve<ExcelStepFormatter>(); | ||
var step = new Step | ||
{ | ||
NativeKeyword = "Given", | ||
Name = "I have some precondition", | ||
Comments = new List<Comment>() | ||
{ | ||
new Comment() | ||
{ | ||
Text = "# A comment - line 1", | ||
Type = CommentType.StepComment | ||
}, | ||
new Comment() | ||
{ | ||
Text = "# A comment - line 2", | ||
Type = CommentType.StepComment | ||
} | ||
} | ||
}; | ||
|
||
using (var workbook = new XLWorkbook()) | ||
{ | ||
IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); | ||
int row = 5; | ||
excelStepFormatter.Format(worksheet, step, ref row); | ||
|
||
Check.That(worksheet.Cell("C5").Value).IsEqualTo(step.Comments[0].Text); | ||
Check.That(worksheet.Cell("C6").Value).IsEqualTo(step.Comments[1].Text); | ||
Check.That(worksheet.Cell("C7").Value).IsEqualTo(step.NativeKeyword); | ||
Check.That(worksheet.Cell("D7").Value).IsEqualTo(step.Name); | ||
} | ||
} | ||
|
||
[Test] | ||
public void ThenCommentsAfterTheLastStepAreAddedSuccesfully() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Successfully is spelled with three s in total :-) |
||
{ | ||
var excelStepFormatter = Container.Resolve<ExcelStepFormatter>(); | ||
var step = new Step | ||
{ | ||
NativeKeyword = "Given", | ||
Name = "I have some precondition", | ||
Comments = new List<Comment>() | ||
{ | ||
new Comment() | ||
{ | ||
Text = "# A comment", | ||
Type = CommentType.StepComment | ||
}, | ||
new Comment() | ||
{ | ||
Text = "# A comment the last step", | ||
Type = CommentType.AfterLastStepComment | ||
} | ||
} | ||
}; | ||
|
||
using (var workbook = new XLWorkbook()) | ||
{ | ||
IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); | ||
int row = 5; | ||
excelStepFormatter.Format(worksheet, step, ref row); | ||
|
||
Check.That(worksheet.Cell("C5").Value).IsEqualTo(step.Comments.First(o => o.Type == CommentType.StepComment).Text); | ||
Check.That(worksheet.Cell("C6").Value).IsEqualTo(step.NativeKeyword); | ||
Check.That(worksheet.Cell("D6").Value).IsEqualTo(step.Name); | ||
Check.That(worksheet.Cell("C7").Value).IsEqualTo(step.Comments.First(o => o.Type == CommentType.AfterLastStepComment).Text); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the unused using