public async Task CompleteAsync_SavesChanges() { var mockContext = new Mock <CountryContext>(); var service = new TestUnitofWork(mockContext.Object); // Act await service.CompleteAsync(); mockContext.Verify(m => m.SaveChangesAsync(), Times.AtLeastOnce); }
public void OrganizationRepository_Returns_InstanceOf_IOrganizationRepository() { var mockContext = new Mock <CountryContext>(); var service = new TestUnitofWork(mockContext.Object); // Act var r = service.OrganizationRepository; var r2 = service.OrganizationRepository; Assert.IsNotNull(r); Assert.IsInstanceOfType(r, typeof(IOrganizationRepository)); Assert.AreSame(r, r2); }
public void Propagates_Same_Context() { var mockContext = new Mock <CountryContext>(); var service = new TestUnitofWork(mockContext.Object); // Act CountryRepository countryRep = service.CountryRepository as CountryRepository; CurrencyRepository currencyRep = service.CurrencyRepository as CurrencyRepository; OrganizationRepository orgRep = service.OrganizationRepository as OrganizationRepository; Assert.IsNotNull(countryRep); Assert.IsNotNull(currencyRep); Assert.IsNotNull(orgRep); Assert.AreSame(countryRep.Context, currencyRep.Context); Assert.AreSame(countryRep.Context, orgRep.Context); }