Created
          January 23, 2023 10:45 
        
      - 
      
 - 
        
Save JamesTryand/3ac5b5816446ea5e2cacc655aa6cfeea to your computer and use it in GitHub Desktop.  
    example of tests in BDD style for eventsourcing library
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | public class DomainModelTests { | |
| [Fact] | |
| public void ANewModelWillHaveNoUncommittedChangesTest() { | |
| new SimpleDomainModel().Changes().ShouldBeEmpty(); | |
| } | |
| [Fact] | |
| public void ANewModelDoingNothingWIllHaveNoUncommittedChanges() { | |
| TestResult<SimpleDomainModel> test = new TestHarness<SimpleDomainModel>(). | |
| Given(TestHelpers.NoEvents). | |
| When(TestHelpers.NothingHappensWith<SimpleDomainModel>()). | |
| Then( | |
| events => events.Count() == 0 | |
| ); | |
| test.Result.ShouldBeTrue(test.Message); | |
| } | |
| [Fact] | |
| public void AModelWithASingleEntryTest() { | |
| TestResult<SimpleDomainModel> test = new TestHarness<SimpleDomainModel>(). | |
| Given(new ThingamajigCreated()). | |
| When(subject => subject.AddItem("Hello")). | |
| Then( | |
| events => events.Count() == 1, | |
| events => events.First() is ItemAddedEvent | |
| ); | |
| test.Result.ShouldBeTrue(test.Message); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment