public virtual async Task Migrate()
        {
            var breedItem1 = new Breed();

            breedItem1.SetProperties(1, "A", 1);
            this.Context.Breeds.Add(breedItem1);

            var paymentTypeItem1 = new PaymentType();

            paymentTypeItem1.SetProperties(1, "A");
            this.Context.PaymentTypes.Add(paymentTypeItem1);

            var penItem1 = new Pen();

            penItem1.SetProperties(1, "A");
            this.Context.Pens.Add(penItem1);

            var petItem1 = new Pet();

            petItem1.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A", 1, 1m);
            this.Context.Pets.Add(petItem1);

            var saleItem1 = new Sale();

            saleItem1.SetProperties(1, 1m, "A", "A", 1, 1, "A");
            this.Context.Sales.Add(saleItem1);

            var speciesItem1 = new Species();

            speciesItem1.SetProperties(1, "A");
            this.Context.Species.Add(speciesItem1);

            await this.Context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async void Create()
        {
            Mock <ILogger <BreedRepository> > loggerMoc = BreedRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BreedRepositoryMoc.GetContext();
            var repository = new BreedRepository(loggerMoc.Object, context);

            var entity = new Breed();

            entity.SetProperties(default(int), "B", 1);
            await repository.Create(entity);

            var records = await context.Set <Breed>().ToListAsync();

            records.Count.Should().Be(2);
        }
Ejemplo n.º 3
0
        public async void Get()
        {
            Mock <ILogger <BreedRepository> > loggerMoc = BreedRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BreedRepositoryMoc.GetContext();
            var repository = new BreedRepository(loggerMoc.Object, context);

            Breed entity = new Breed();

            entity.SetProperties(default(int), "B", 1);
            context.Set <Breed>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
Ejemplo n.º 4
0
        public async void DeleteFound()
        {
            Mock <ILogger <BreedRepository> > loggerMoc = BreedRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BreedRepositoryMoc.GetContext();
            var   repository             = new BreedRepository(loggerMoc.Object, context);
            Breed entity = new Breed();

            entity.SetProperties(default(int), "B", 1);
            context.Set <Breed>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            var records = await context.Set <Breed>().ToListAsync();

            records.Count.Should().Be(1);
        }
Ejemplo n.º 5
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <BreedRepository> > loggerMoc = BreedRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BreedRepositoryMoc.GetContext();
            var   repository             = new BreedRepository(loggerMoc.Object, context);
            Breed entity = new Breed();

            entity.SetProperties(default(int), "B", 1);
            context.Set <Breed>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

            var records = await context.Set <Breed>().ToListAsync();

            records.Count.Should().Be(2);
        }