private static async Task TestDeleteWithTwoCompositePrimaryKeyAsync(IUnitOfWorkFactory uowFactory) { var repo = new Service <CustomerWithTwoCompositePrimaryKey, int, string>(uowFactory); var key1 = 1; var key2 = "2"; var entity = new CustomerWithTwoCompositePrimaryKey { Id1 = key1, Id2 = key2, Name = "Random Name" }; Assert.False(await repo.GetExistsAsync(key1, key2)); await repo.CreateAsync(entity); Assert.True(await repo.GetExistsAsync(key1, key2)); await repo.DeleteAsync(key1, key2); Assert.False(await repo.GetExistsAsync(key1, key2)); }
private static async Task TestGetWithTwoCompositePrimaryKeyAsync(IServiceFactory serviceFactory) { var repo = serviceFactory.Create <CustomerWithTwoCompositePrimaryKey, int, string>(); var key1 = 1; var key2 = "2"; var fetchStrategy = new FetchQueryStrategy <CustomerWithTwoCompositePrimaryKey>(); var entity = new CustomerWithTwoCompositePrimaryKey { Id1 = key1, Id2 = key2, Name = "Random Name" }; Assert.Null(await repo.GetAsync(key1, key2)); Assert.Null(await repo.GetAsync(key1, key2, fetchStrategy)); await repo.CreateAsync(entity); Assert.NotNull(await repo.GetAsync(key1, key2)); Assert.NotNull(await repo.GetAsync(key1, key2, fetchStrategy)); }
private static async Task TestDeleteWithTwoCompositePrimaryKeyAsync(IRepositoryFactory repoFactory) { var repo = repoFactory.Create <CustomerWithTwoCompositePrimaryKey, int, string>(); var key1 = 1; var key2 = "2"; var entity = new CustomerWithTwoCompositePrimaryKey { Id1 = key1, Id2 = key2, Name = "Random Name" }; Assert.False(await repo.ExistsAsync(key1, key2)); await repo.AddAsync(entity); Assert.True(await repo.ExistsAsync(key1, key2)); await repo.DeleteAsync(key1, key2); Assert.False(await repo.ExistsAsync(key1, key2)); }
private static void TestDeleteWithTwoCompositePrimaryKey(IServiceFactory serviceFactory) { var repo = serviceFactory.Create <CustomerWithTwoCompositePrimaryKey, int, string>(); var key1 = 1; var key2 = "2"; var entity = new CustomerWithTwoCompositePrimaryKey { Id1 = key1, Id2 = key2, Name = "Random Name" }; Assert.False(repo.GetExists(key1, key2)); repo.Create(entity); Assert.True(repo.GetExists(key1, key2)); repo.Delete(key1, key2); Assert.False(repo.GetExists(key1, key2)); }
private static void TestGetWithTwoCompositePrimaryKey(IUnitOfWorkFactory uowFactory) { var repo = new Service <CustomerWithTwoCompositePrimaryKey, int, string>(uowFactory); var key1 = 1; var key2 = "2"; var randomKey = "3"; var fetchStrategy = new FetchQueryStrategy <CustomerWithTwoCompositePrimaryKey>(); var entity = new CustomerWithTwoCompositePrimaryKey { Id1 = key1, Id2 = key2, Name = "Random Name" }; Assert.Null(repo.Get(key1, key2)); Assert.Null(repo.Get(key1, key2, fetchStrategy)); repo.Create(entity); Assert.Null(repo.Get(key1, randomKey)); Assert.Null(repo.Get(key1, randomKey, fetchStrategy)); Assert.NotNull(repo.Get(key1, key2)); Assert.NotNull(repo.Get(key1, key2, fetchStrategy)); }