ICalcSalesTaxService _taxLookupService; //#C public LocationChangedEventHandler( //#D DomainEventsDbContext context, //#D ICalcSalesTaxService taxLookupService) //#D { //#D _context = context; //#D _taxLookupService = taxLookupService; //#D } //#D
public void TestNewQuoteCreatesEventOk() { //SETUP var options = SqliteInMemory.CreateOptions <DomainEventsDbContext>(); using var context = new DomainEventsDbContext(options); context.Database.EnsureCreated(); //ATTEMPT var quote = new Quote(null); //VERIFY var foundEvent = quote.GetEventsThenClear().Single(); foundEvent.ShouldBeType <QuoteLocationChangedEvent>(); ((QuoteLocationChangedEvent)foundEvent).NewLocation.ShouldEqual(null); }
public void TestAddEventManuallyOk() { //SETUP var options = SqliteInMemory.CreateOptions <DomainEventsDbContext>(); using var context = new DomainEventsDbContext(options); context.Database.EnsureCreated(); //ATTEMPT var location = context.Locations.First(); location.State = "Test"; //VERIFY var foundEvent = location.GetEventsThenClear().Single(); foundEvent.ShouldBeType <LocationChangedEvent>(); ((LocationChangedEvent)foundEvent).Location.State.ShouldEqual("Test"); location.GetEventsThenClear().Count.ShouldEqual(0); }
public void TestEventsDbContextSeededOk() { //SETUP var options = SqliteInMemory.CreateOptions <DomainEventsDbContext>(); using var context = new DomainEventsDbContext(options); //ATTEMPT context.Database.EnsureCreated(); //VERIFY context.SalesTaxes.Count().ShouldEqual(4); context.Locations.Count().ShouldEqual(3); int i = 1; foreach (var location in context.Locations) { location.Name.ShouldEqual($"Place{i++}"); location.State.ShouldEqual("005"); } }
public CalcSalesTaxService(DomainEventsDbContext context) { _context = context; }