Exemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <VenueRepository> > loggerMoc = VenueRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VenueRepositoryMoc.GetContext();
            var repository = new VenueRepository(loggerMoc.Object, context);

            var entity = new Venue();

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

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

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

            Venue entity = new Venue();

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async void DeleteFound()
        {
            Mock <ILogger <VenueRepository> > loggerMoc = VenueRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VenueRepositoryMoc.GetContext();
            var   repository             = new VenueRepository(loggerMoc.Object, context);
            Venue entity = new Venue();

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

            await repository.Delete(entity.Id);

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

            records.Count.Should().Be(1);
        }
Exemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <VenueRepository> > loggerMoc = VenueRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VenueRepositoryMoc.GetContext();
            var   repository             = new VenueRepository(loggerMoc.Object, context);
            Venue entity = new Venue();

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

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

            await repository.Update(entity);

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

            records.Count.Should().Be(2);
        }
        public virtual async Task Migrate()
        {
            var adminItem1 = new Admin();

            adminItem1.SetProperties(1, "A", "A", "A", "A", "A", "A");
            this.Context.Admins.Add(adminItem1);

            var cityItem1 = new City();

            cityItem1.SetProperties(1, "A", 1);
            this.Context.Cities.Add(cityItem1);

            var countryItem1 = new Country();

            countryItem1.SetProperties(1, "A");
            this.Context.Countries.Add(countryItem1);

            var customerItem1 = new Customer();

            customerItem1.SetProperties(1, "A", "A", "A", "A");
            this.Context.Customers.Add(customerItem1);

            var eventItem1 = new Event();

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

            var provinceItem1 = new Province();

            provinceItem1.SetProperties(1, 1, "A");
            this.Context.Provinces.Add(provinceItem1);

            var saleItem1 = new Sale();

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

            var saleTicketsItem1 = new SaleTickets();

            saleTicketsItem1.SetProperties(1, 1, 1);
            this.Context.SaleTickets.Add(saleTicketsItem1);

            var ticketItem1 = new Ticket();

            ticketItem1.SetProperties(1, "A", 1);
            this.Context.Tickets.Add(ticketItem1);

            var ticketStatusItem1 = new TicketStatus();

            ticketStatusItem1.SetProperties(1, "A");
            this.Context.TicketStatus.Add(ticketStatusItem1);

            var transactionItem1 = new Transaction();

            transactionItem1.SetProperties(1, 1m, "A", 1);
            this.Context.Transactions.Add(transactionItem1);

            var transactionStatusItem1 = new TransactionStatus();

            transactionStatusItem1.SetProperties(1, "A");
            this.Context.TransactionStatus.Add(transactionStatusItem1);

            var venueItem1 = new Venue();

            venueItem1.SetProperties(1, "A", "A", 1, "A", "A", "A", "A", 1, "A");
            this.Context.Venues.Add(venueItem1);

            await this.Context.SaveChangesAsync();
        }