Skip to content

Commit

Permalink
Added test to show that SaveChangesAsync not works when the insert fu…
Browse files Browse the repository at this point in the history
…nction of a service is used.
  • Loading branch information
Alfred Brockotter committed Feb 27, 2018
1 parent a5bcc2b commit a5dce51
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions URF.Core.EF.Tests/ServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Customer> customerRepository = new TrackableRepository<Customer>(_fixture.Context);
ITrackableRepository<Order> orderRepository = new TrackableRepository<Order>(_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<int>(1, savedChanges);
}
}
}

0 comments on commit a5dce51

Please sign in to comment.