diff --git a/URF.Core.EF.Tests/ServiceTest.cs b/URF.Core.EF.Tests/ServiceTest.cs index 325094d..dea40ec 100644 --- a/URF.Core.EF.Tests/ServiceTest.cs +++ b/URF.Core.EF.Tests/ServiceTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Urf.Core.Abstractions; using URF.Core.Abstractions.Trackable; using URF.Core.EF.Tests.Contexts; using URF.Core.EF.Tests.Models; @@ -75,5 +76,27 @@ public async Task CustomersByCompany_Should_Return_Customer() Assert.Collection(customers, customer => Assert.Equal("ALFKI", customer.CustomerId)); } + + + [Fact] + public async Task Insert_Customer_Should_Save_Changes() + { + IUnitOfWork unitOfWork = new UnitOfWork(_fixture.Context); + ITrackableRepository customerRepository = new TrackableRepository(_fixture.Context); + ITrackableRepository orderRepository = new TrackableRepository(_fixture.Context); + var customerService = new CustomerService(customerRepository, orderRepository); + + var cust = new Customer + { + CustomerId = "COMP1", + CompanyName = "Company 1" + }; + + customerService.Insert(cust); + Assert.Equal(TrackableEntities.Common.Core.TrackingState.Added, cust.TrackingState); + + var savedChanges = await unitOfWork.SaveChangesAsync(); + Assert.Equal(1, savedChanges); + } } } \ No newline at end of file