Browse Source

Added test: Repository_Basic_Tests_With_Int_Pk

pull/1810/head
Halil İbrahim Kalkan 7 years ago
parent
commit
7e4f1f3439
  1. 9
      framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Repositories/Repository_Basic_Tests_With_Int_Pk.cs
  2. 2
      framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/TestMigrationsDbContext.cs
  3. 2
      framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContext.cs
  4. 9
      framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/Repositories/Repository_Basic_Tests_With_Int_Pk.cs
  5. 3
      framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/TestApp/MemoryDb/TestAppMemoryDbContext.cs
  6. 9
      framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Repositories/Repository_Basic_Tests_With_Int_Pk.cs
  7. 4
      framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/TestApp/MongoDb/TestAppMongoDbContext.cs
  8. 22
      framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/EntityWithIntPk.cs
  9. 11
      framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestDataBuilder.cs
  10. 42
      framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/Repository_Basic_Tests_With_Int_Pk.cs

9
framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Repositories/Repository_Basic_Tests_With_Int_Pk.cs

@ -0,0 +1,9 @@
using Volo.Abp.TestApp.Testing;
namespace Volo.Abp.EntityFrameworkCore.Repositories
{
public class Repository_Basic_Tests_With_Int_Pk : Repository_Basic_Tests_With_Int_Pk<AbpEntityFrameworkCoreTestModule>
{
}
}

2
framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/TestMigrationsDbContext.cs

@ -15,6 +15,8 @@ namespace Volo.Abp.EntityFrameworkCore
public DbSet<BookInSecondDbContext> Books { get; set; }
public DbSet<EntityWithIntPk> EntityWithIntPks { get; set; }
public TestMigrationsDbContext(DbContextOptions<TestMigrationsDbContext> options)
: base(options)
{

2
framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContext.cs

@ -13,6 +13,8 @@ namespace Volo.Abp.TestApp.EntityFrameworkCore
public DbSet<ThirdDbContextDummyEntity> DummyEntities { get; set; }
public DbSet<EntityWithIntPk> EntityWithIntPks { get; set; }
public TestAppDbContext(DbContextOptions<TestAppDbContext> options)
: base(options)
{

9
framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/Repositories/Repository_Basic_Tests_With_Int_Pk.cs

@ -0,0 +1,9 @@
using Volo.Abp.TestApp.Testing;
namespace Volo.Abp.MemoryDb.Repositories
{
public class Repository_Basic_Tests_With_Int_Pk : Repository_Basic_Tests_With_Int_Pk<AbpMemoryDbTestModule>
{
}
}

3
framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/TestApp/MemoryDb/TestAppMemoryDbContext.cs

@ -8,7 +8,8 @@ namespace Volo.Abp.TestApp.MemoryDb
public class TestAppMemoryDbContext : MemoryDbContext
{
private static readonly Type[] EntityTypeList = {
typeof(Person)
typeof(Person),
typeof(EntityWithIntPk)
};
public override IReadOnlyList<Type> GetEntityTypes()

9
framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Repositories/Repository_Basic_Tests_With_Int_Pk.cs

@ -0,0 +1,9 @@
using Volo.Abp.TestApp.Testing;
namespace Volo.Abp.MongoDB.Repositories
{
public class Repository_Basic_Tests_With_Int_Pk : Repository_Basic_Tests_With_Int_Pk<AbpMongoDbTestModule>
{
}
}

4
framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/TestApp/MongoDb/TestAppMongoDbContext.cs

@ -8,9 +8,11 @@ namespace Volo.Abp.TestApp.MongoDB
[ConnectionStringName("TestApp")]
public class TestAppMongoDbContext : AbpMongoDbContext, ITestAppMongoDbContext
{
[MongoCollection("Persons")] //Intentially changed the collection name to test it
[MongoCollection("Persons")] //Intentionally changed the collection name to test it
public IMongoCollection<Person> People => Collection<Person>();
public IMongoCollection<EntityWithIntPk> EntityWithIntPks => Collection<EntityWithIntPk>();
public IMongoCollection<City> Cities => Collection<City>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)

22
framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/EntityWithIntPk.cs

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.TestApp.Domain
{
public class EntityWithIntPk : AggregateRoot<int>
{
public string Name { get; set; }
public EntityWithIntPk()
{
}
public EntityWithIntPk(string name)
{
Name = name;
}
}
}

11
framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestDataBuilder.cs

@ -17,19 +17,23 @@ namespace Volo.Abp.TestApp
private readonly IBasicRepository<Person, Guid> _personRepository;
private readonly ICityRepository _cityRepository;
private readonly IRepository<EntityWithIntPk, int> _entityWithIntPksRepository;
public TestDataBuilder(
IBasicRepository<Person, Guid> personRepository,
ICityRepository cityRepository)
ICityRepository cityRepository,
IRepository<EntityWithIntPk, int> entityWithIntPksRepository)
{
_personRepository = personRepository;
_cityRepository = cityRepository;
_entityWithIntPksRepository = entityWithIntPksRepository;
}
public void Build()
{
AddCities();
AddPeople();
AddEntitiesWithPks();
}
private void AddCities()
@ -63,5 +67,10 @@ namespace Volo.Abp.TestApp
_personRepository.Insert(tenant1Person1);
_personRepository.Insert(tenant1Person2);
}
private void AddEntitiesWithPks()
{
_entityWithIntPksRepository.Insert(new EntityWithIntPk("Entity1"));
}
}
}

42
framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/Repository_Basic_Tests_With_Int_Pk.cs

@ -0,0 +1,42 @@
using System.Linq;
using Shouldly;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Modularity;
using Volo.Abp.TestApp.Domain;
using Xunit;
namespace Volo.Abp.TestApp.Testing
{
public abstract class Repository_Basic_Tests_With_Int_Pk<TStartupModule> : TestAppTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
protected readonly IRepository<EntityWithIntPk, int> EntityWithIntPkRepository;
protected Repository_Basic_Tests_With_Int_Pk()
{
EntityWithIntPkRepository = GetRequiredService<IRepository<EntityWithIntPk, int>>();
}
[Fact]
public void FirstOrDefault()
{
WithUnitOfWork(() =>
{
var entity = EntityWithIntPkRepository.FirstOrDefault(e => e.Name == "Entity1");
entity.ShouldNotBeNull();
entity.Name.ShouldBe("Entity1");
});
}
[Fact]
public void Get()
{
WithUnitOfWork(() =>
{
var entity = EntityWithIntPkRepository.Get(1);
entity.ShouldNotBeNull();
entity.Name.ShouldBe("Entity1");
});
}
}
}
Loading…
Cancel
Save