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();
        }
Example #2
0
        public async void Create()
        {
            Mock <ILogger <SpeciesRepository> > loggerMoc = SpeciesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpeciesRepositoryMoc.GetContext();
            var repository = new SpeciesRepository(loggerMoc.Object, context);

            var entity = new Species();

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

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

            records.Count.Should().Be(2);
        }
Example #3
0
        public async void Get()
        {
            Mock <ILogger <SpeciesRepository> > loggerMoc = SpeciesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpeciesRepositoryMoc.GetContext();
            var repository = new SpeciesRepository(loggerMoc.Object, context);

            Species entity = new Species();

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

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

            record.Should().NotBeNull();
        }
Example #4
0
        public async void DeleteFound()
        {
            Mock <ILogger <SpeciesRepository> > loggerMoc = SpeciesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpeciesRepositoryMoc.GetContext();
            var     repository           = new SpeciesRepository(loggerMoc.Object, context);
            Species entity = new Species();

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

            await repository.Delete(entity.Id);

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

            records.Count.Should().Be(1);
        }
Example #5
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SpeciesRepository> > loggerMoc = SpeciesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpeciesRepositoryMoc.GetContext();
            var     repository           = new SpeciesRepository(loggerMoc.Object, context);
            Species entity = new Species();

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

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

            await repository.Update(entity);

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

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