Created
November 13, 2019 11:55
-
-
Save marcingolenia/ea955cfa99b3b723c9a7fc966fd86fe1 to your computer and use it in GitHub Desktop.
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
namespace Invoicing.BehaviourTests | |
{ | |
using TestStack.BDDfy; | |
using Xunit; | |
public class UnitTest1 | |
{ | |
private decimal _result; | |
private decimal _value1; | |
private decimal _value2; | |
[Theory] | |
[InlineData(1, 2, 3)] | |
[InlineData(1.2, 2.3, 3.5)] | |
public void ShouldBeAbleToAddTwoNumbers(decimal value1, decimal value2, decimal result) => | |
this.Given(_ => _.GivenIHaveTwoValues(value1, value2)) | |
.When(_ => _.WhenIAddThem()) | |
.Then(_ => _.ThenIGetTheExpectedResult(result)) | |
.BDDfy(); | |
private void GivenIHaveTwoValues(decimal value1, decimal value2) | |
{ | |
_value1 = value1; | |
_value2 = value2; | |
} | |
private void WhenIAddThem() => _result = _value1 + _value2; | |
private void ThenIGetTheExpectedResult(decimal result) => Assert.Equal(_result, result); | |
} | |
} | |
namespace Invoicing.BehaviourTests | |
{ | |
using System; | |
using TestStack.BDDfy; | |
using Xunit; | |
public class Class1 | |
{ | |
[Fact] | |
public void CreatingCorrectionForBillingItemWhenSumOfInvoicedBillingItemsIsGreaterThan0() | |
{ | |
var test = 1; | |
var test2 = "Marcin"; | |
this.Given(_ => _.SettledBillingItem1(test)) | |
.And(_ => _.NotInvoicedBillingItem2(test2)) | |
.And(_ => _.BillingItem2HasAReservationId()) | |
.When(_ => _.BillingItem2IsInvoiced()) | |
.And(_ => _.BillingItem2_ReservationIdEqualsBillingItem1_ReservationId()) | |
.And(_ => _.TotalToPayIsGreaterThan0()) | |
.Then(_ => _.BillingItem2IsInvoicedAsInvoiceAndWillBeAttachedToAttachment()) | |
.WithExamples(new ExampleTable("test", "test2") | |
{ | |
{11, "Marcin2" }, | |
{2221, "Marcin222" } | |
}) | |
.BDDfy(); | |
} | |
private void BillingItem2IsInvoicedAsInvoiceAndWillBeAttachedToAttachment() => | |
throw new NotImplementedException(); | |
private void BillingItem2HasAReservationId() => throw new NotImplementedException(); | |
private void NotInvoicedBillingItem2(string s) => throw new NotImplementedException(); | |
private void SettledBillingItem1(int a) => throw new NotImplementedException(); | |
private void BillingItem2IsInvoiced() => throw new NotImplementedException(); | |
private void BillingItem2_ReservationIdEqualsBillingItem1_ReservationId() => | |
throw new NotImplementedException(); | |
private void TotalToPayIsGreaterThan0() => throw new NotImplementedException(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment