コード例 #1
0
        public async void Create()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var repository = new SaleTicketsRepository(loggerMoc.Object, context);

            var entity = new SaleTickets();

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

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

            records.Count.Should().Be(2);
        }
コード例 #2
0
        public async void Get()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var repository = new SaleTicketsRepository(loggerMoc.Object, context);

            SaleTickets entity = new SaleTickets();

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

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

            record.Should().NotBeNull();
        }
コード例 #3
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SaleTicketsRepository> > loggerMoc = SaleTicketsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SaleTicketsRepositoryMoc.GetContext();
            var         repository       = new SaleTicketsRepository(loggerMoc.Object, context);
            SaleTickets entity           = new SaleTickets();

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

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

            await repository.Update(entity);

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

            records.Count.Should().Be(2);
        }
コード例 #4
0
        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();
        }