-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ #241 (LightBDD.Framework)(New) Added WithInferredColumns(InferredColumnsOrder columnsOrder) method to IInputTableBuilder and IVerifiableDataTableBuilder with option to add inferred columns in name or declaration order + #264 (LightBDD.Framework)(Fix) Corrected Html Report to expand feature background with the content + #265 (LightBDD.Framework)(Fix) Fixed InputTable and VerifiableTable to include Item column if no other columns are present and fail if provided object count and instances do not match + #265 (LightBDD.Core)(New) Added IFormatSymbols.EmptyValue property + #265 (LightBDD.Core)(New) Added IValueFormattingService.Symbols property + #265 (LightBDD.Framework)(Change) Updated CollectionFormatter and DictionaryFormatter to format empty collections + #268 (LightBDD.Framework)(New) Added InputTree<T> to provide detailed insights into the object structure upon progress and results rendering. + #268 (LightBDD.Framework)(New) Added VerifiableTree<T> to provide detailed structural verification of actual versus expected object hierarchies + #268 (LightBDD.Framework)(New) Added Tree class with a set of methods to create InputTree<T> and VerifiableTree<T> parameters + #268 (LightBDD.Framework)(Change) Equal() expectation supports now comparison of numeric types that have equivalent values, i.e. 5.0 (double) to 5 (int) + #268 (LightBDD.Framework)(Change) CastFrom() expectation support now conversions of numeric types that have equivalent values, i.e. 5.0 (double) to 5 (int) + #268 (LightBDD.Framework)(Change) InputTable value cells are rendered on Html Report with background color being consistent with color of non-verifiable parameters (pink) + #273 (LightBDD.XUnit2)(Change) Updated integration to detect exceptions thrown in LightBddScopeAttribute.OnSetUp() and fail scenarios instead of breaking test pipeline
- Loading branch information
Showing
150 changed files
with
6,517 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyCopyright("Copyright © Wojciech Kotlarski 2013-2021")] | ||
[assembly: AssemblyVersion("3.5.0")] | ||
[assembly: AssemblyFileVersion("3.5.0")] | ||
[assembly: AssemblyInformationalVersion("3.5.0")] | ||
[assembly: AssemblyCopyright("Copyright © Wojciech Kotlarski 2013-2023")] | ||
[assembly: AssemblyVersion("3.6.0")] | ||
[assembly: AssemblyFileVersion("3.6.0")] | ||
[assembly: AssemblyInformationalVersion("3.6.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Example.Domain.Domain | ||
{ | ||
public class AddressBook | ||
{ | ||
private readonly Dictionary<string, ContactAddress> _contactsByEmail = new Dictionary<string, ContactAddress>(); | ||
public IReadOnlyDictionary<string, ContactAddress> ContactsByEmail => _contactsByEmail; | ||
|
||
public void AddContactAddress(ContactAddress contact) { _contactsByEmail[contact.Contact.Email] = contact; } | ||
|
||
public IEnumerable<Contact> GetContacts() => _contactsByEmail.Values.Select(x => x.Contact).OrderBy(x => x.Name); | ||
|
||
public IEnumerable<PostalAddress> GetAddresses() => _contactsByEmail.Values.Select(x => x.Address).OrderBy(x => x.Country).ThenBy(x => x.PostCode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Example.Domain.Domain | ||
{ | ||
public class ContactAddress | ||
{ | ||
public string Alias { get; set; } | ||
public Contact Contact { get; } | ||
public PostalAddress Address { get; set; } | ||
|
||
public ContactAddress(string alias,Contact contact, PostalAddress address) | ||
{ | ||
Alias = alias; | ||
Contact = contact; | ||
Address = address; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Example.Domain.Domain | ||
{ | ||
public class PostalAddress | ||
{ | ||
public string Address { get; } | ||
public string City { get; } | ||
public string PostCode { get; } | ||
public string Country { get; } | ||
|
||
public PostalAddress(string country, string city, string postCode, string address) | ||
{ | ||
Address = address; | ||
City = city; | ||
PostCode = postCode; | ||
Country = country; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
examples/Example.LightBDD.Fixie2/Features/Address_book_feature.Steps.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System.Text.Json; | ||
using Example.Domain.Domain; | ||
using LightBDD.Fixie2; | ||
using LightBDD.Framework; | ||
using LightBDD.Framework.Parameters; | ||
|
||
namespace Example.LightBDD.Fixie2.Features | ||
{ | ||
public partial class Address_book_feature : FeatureFixture | ||
{ | ||
private AddressBook _book; | ||
private string _json; | ||
|
||
private void Given_an_empty_address_book() | ||
{ | ||
_book = new AddressBook(); | ||
} | ||
|
||
private void When_I_associate_contact_with_address_as_alias(InputTree<Contact> contact, InputTree<PostalAddress> address, string alias) | ||
{ | ||
_book.AddContactAddress(new ContactAddress(alias, contact.Input, address.Input)); | ||
} | ||
|
||
private void Then_address_by_email_should_match(VerifiableTree match) | ||
{ | ||
match.SetActual(_book.ContactsByEmail); | ||
} | ||
|
||
private void Given_an_address_book_with_contacts(InputTree<ContactAddress[]> contacts) | ||
{ | ||
_book = new AddressBook(); | ||
foreach (var address in contacts.Input) | ||
_book.AddContactAddress(address); | ||
} | ||
|
||
private void When_I_persist_book_as_json() | ||
{ | ||
_json = JsonSerializer.Serialize(_book); | ||
} | ||
|
||
private void Then_address_book_should_match_persisted_json(VerifiableTree json) | ||
{ | ||
StepExecution.Current.Comment($"Underlying type: {json.Expected?.GetType().Name}"); | ||
json.SetActual(_book); | ||
} | ||
|
||
private void Then_address_book_should_contain_contacts(VerifiableTree<Contact[]> contacts) | ||
{ | ||
contacts.SetActual(_book.GetContacts()); | ||
} | ||
|
||
private void Then_address_book_should_contain_postal_addresses(VerifiableTree addresses) | ||
{ | ||
addresses.SetActual(_book.GetAddresses()); | ||
} | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
examples/Example.LightBDD.Fixie2/Features/Address_book_feature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
using System.Text.Json; | ||
using Example.Domain.Domain; | ||
using LightBDD.Fixie2; | ||
using LightBDD.Framework; | ||
using LightBDD.Framework.Parameters; | ||
using LightBDD.Framework.Scenarios; | ||
using Newtonsoft.Json; | ||
|
||
namespace Example.LightBDD.Fixie2.Features | ||
{ | ||
/// <summary> | ||
/// This feature class presents the usage of <see cref="InputTree{TData}"/> and <see cref="VerifiableTree{TData}"/> parameter types to structurally verify and visualize hierarchical object structure. | ||
/// </summary> | ||
[FeatureDescription( | ||
@"In order to maintain my product dispatch | ||
As an application user | ||
I want to add and browse my client postal addresses by client emails")] | ||
public partial class Address_book_feature | ||
{ | ||
[Scenario] | ||
public void Adding_contacts() | ||
{ | ||
Runner.RunScenario( | ||
_ => Given_an_empty_address_book(), | ||
_ => When_I_associate_contact_with_address_as_alias( | ||
new Contact("Joe Jonnes", "666777888", "joe67@email.com"), | ||
new PostalAddress("UK", "London", "AB1 2CD", "47 Main Street"), | ||
"Joey"), | ||
_ => When_I_associate_contact_with_address_as_alias( | ||
new Contact("Jan Nowak", "123654789", "nowak33@email.com"), | ||
new PostalAddress("Poland", "Kraków", "31-042", "Rynek Główny 1"), | ||
"Janek"), | ||
_ => Then_address_book_should_contain_contacts(Tree.ExpectEquivalent(new[] | ||
{ | ||
new Contact("Jan Nowak", "123654789", "nowak33@email.com"), | ||
new Contact("Joel Jonnes", "666777888", "joe67@email.com") | ||
}))); | ||
} | ||
|
||
[Scenario] | ||
public void Matching_addresses_by_email() | ||
{ | ||
Runner.RunScenario( | ||
_ => Given_an_empty_address_book(), | ||
_ => When_I_associate_contact_with_address_as_alias( | ||
new Contact("Joe Jonnes", "666777888", "joe67@email.com"), | ||
new PostalAddress("UK", "London", "AB1 2CD", "47 Main Street"), | ||
"Joey"), | ||
_ => When_I_associate_contact_with_address_as_alias( | ||
new Contact("Jan Nowak", "123654789", "nowak33@email.com"), | ||
new PostalAddress("Poland", "Kraków", "31-042", "Rynek Główny 1"), | ||
"Janek"), | ||
_ => Then_address_by_email_should_match(Tree.ExpectContaining(new Dictionary<string, object> | ||
{ | ||
{ | ||
"nowak33@email.com", | ||
new | ||
{ | ||
Address = new { City = "Kraków", PostCode = "31-042", Address = "Rynek Główny 1" } | ||
} | ||
}, | ||
{ | ||
"joe67@email.com", | ||
new | ||
{ | ||
Address = new { City = "London", PostCode = "AB1 2CD", Address = "47 Main Street" } | ||
} | ||
} | ||
}))); | ||
} | ||
|
||
[Scenario] | ||
public void Persisting_address_book() | ||
{ | ||
Runner.RunScenario( | ||
_ => Given_an_address_book_with_contacts(new[] | ||
{ | ||
new ContactAddress("Joey", | ||
new Contact("Joe Jonnes", "666777888", "joe67@email.com"), | ||
new PostalAddress("UK", "London", "AB1 2CD", "47 Main Street")), | ||
new ContactAddress("Janek", | ||
new Contact("Jan Nowak", "123654789", "nowak33@email.com"), | ||
new PostalAddress("Poland", "Kraków", "31-042", "Rynek Główny 1")) | ||
}), | ||
_ => When_I_persist_book_as_json(), | ||
_ => Then_address_book_should_match_persisted_json(Tree.ExpectEquivalent(JsonDocument.Parse(_json, default).RootElement)), | ||
_ => Then_address_book_should_match_persisted_json(Tree.ExpectEquivalent(JsonConvert.DeserializeObject<ExpandoObject>(_json)))); | ||
} | ||
|
||
[Scenario] | ||
public void Retrieving_postal_addresses() | ||
{ | ||
Runner.RunScenario( | ||
_ => Given_an_empty_address_book(), | ||
_ => When_I_associate_contact_with_address_as_alias( | ||
new Contact("Joe Jonnes", "666777888", "joe67@email.com"), | ||
new PostalAddress("UK", "London", "AB1 2CD", "47 Main Street"), | ||
"Joey"), | ||
_ => When_I_associate_contact_with_address_as_alias( | ||
new Contact("Jan Nowak", "123654789", "nowak33@email.com"), | ||
new PostalAddress("Poland", "Kraków", "31-042", "Rynek Główny 1"), | ||
"Janek"), | ||
_ => Then_address_book_should_contain_postal_addresses(Tree.ExpectEquivalent(new[] | ||
{ | ||
new { Country = "Poland", City = "Kraków", PostCode = "31-042", Address = "Rynek Główny 1" }, | ||
new { Country = "UK", City = "London", PostCode = "AB1 2CD", Address = "47 Main Street" } | ||
})) | ||
); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
examples/Example.LightBDD.Fixie2/Features/Record_persistence_feature.Steps.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using LightBDD.Fixie2; | ||
using LightBDD.Framework.Parameters; | ||
|
||
namespace Example.LightBDD.Fixie2.Features | ||
{ | ||
public partial class Record_persistence_feature : FeatureFixture | ||
{ | ||
class DataRecord | ||
{ | ||
public Guid Id { get; set; } | ||
public DateTimeOffset ModifiedDate { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
private readonly List<DataRecord> _records = new List<DataRecord>(); | ||
|
||
private void Given_no_saved_records() | ||
{ | ||
_records.Clear(); | ||
} | ||
|
||
private void When_I_save_records(InputTree<string[]> records) | ||
{ | ||
foreach (var name in records.Input) | ||
{ | ||
_records.Add(new DataRecord { Id = Guid.NewGuid(), ModifiedDate = DateTimeOffset.UtcNow, Name = name }); | ||
Thread.Sleep(TimeSpan.FromSeconds(1)); | ||
} | ||
} | ||
|
||
private void Then_the_saved_records_should_match_expectation(VerifiableTree expectation) | ||
{ | ||
expectation.SetActual(_records); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
examples/Example.LightBDD.Fixie2/Features/Record_persistence_feature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using LightBDD.Fixie2; | ||
using LightBDD.Framework.Expectations; | ||
using LightBDD.Framework.Parameters; | ||
using LightBDD.Framework.Scenarios; | ||
|
||
namespace Example.LightBDD.Fixie2.Features | ||
{ | ||
/// <summary> | ||
/// This feature class presents the usage of <see cref="InputTree{TData}"/> and <see cref="VerifiableTree{TData}"/> parameter types to structurally verify and visualize hierarchical object structure. | ||
/// </summary> | ||
public partial class Record_persistence_feature | ||
{ | ||
[Scenario] | ||
public void Saving_data() | ||
{ | ||
var testRunDate = DateTimeOffset.UtcNow; | ||
|
||
Runner.RunScenario( | ||
_ => Given_no_saved_records(), | ||
_ => When_I_save_records(new[] { "Record 1", "Record 2" }), | ||
_ => Then_the_saved_records_should_match_expectation(Tree.ExpectEquivalent(new[] | ||
{ | ||
new | ||
{ | ||
Id = Expect.To.Not.Equal(Guid.Empty), | ||
ModifiedDate = Expect.To.BeGreaterOrEqual(testRunDate), | ||
Name = Expect.To.BeLike("Recr*") | ||
}, | ||
new | ||
{ | ||
Id = Expect.To.Equal(Guid.Empty), | ||
ModifiedDate = Expect.To.BeLessThan(testRunDate), | ||
Name = Expect.To.Equal("Record 2") | ||
}, | ||
})) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.