예제 #1
0
 public UserService(MechKeyboardBaseDbContext context)
 {
     _context = context;
 }
        public void Paginator_CheckPaging_ReturnsthecorrectnumberofitemsAsync()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <MechKeyboardBaseDbContext>()
                          .UseInMemoryDatabase("KeyboardInMemoryDB")
                          .Options;

            using (var context = new MechKeyboardBaseDbContext(options))
            {
                context.Keyboard.Add(new Keyboard()
                {
                    KeyboardId   = 7,
                    Username     = "******",
                    KeyboardName = "Test1d",
                    Case         = "test",
                    PCB          = "test",
                    Plate        = "test",
                    Keycaps      = "EPBT test",
                    Switch       = "test Inks"
                });

                context.Keyboard.Add(new Keyboard()
                {
                    KeyboardId   = 8,
                    Username     = "******",
                    KeyboardName = "Test1d",
                    Case         = "test",
                    PCB          = "test",
                    Plate        = "test",
                    Keycaps      = "EPBT test",
                    Switch       = "test Inks"
                });

                context.Keyboard.Add(new Keyboard()
                {
                    KeyboardId   = 9,
                    Username     = "******",
                    KeyboardName = "Test1d",
                    Case         = "test",
                    PCB          = "test",
                    Plate        = "test",
                    Keycaps      = "EPBT test",
                    Switch       = "test Inks"
                });

                context.Keyboard.Add(new Keyboard()
                {
                    KeyboardId   = 10,
                    Username     = "******",
                    KeyboardName = "Test1d",
                    Case         = "test",
                    PCB          = "test",
                    Plate        = "test",
                    Keycaps      = "EPBT test",
                    Switch       = "test Inks"
                });

                context.Keyboard.Add(new Keyboard()
                {
                    KeyboardId   = 11,
                    Username     = "******",
                    KeyboardName = "Test1d",
                    Case         = "test",
                    PCB          = "test",
                    Plate        = "test",
                    Keycaps      = "EPBT test",
                    Switch       = "test Inks"
                });

                context.SaveChanges();

                var keyboardRepository = new KeyboardRepository(context);

                //Act

                var listQuery = keyboardRepository.GetKeyboardsByPageAsync(2, 1);

                //Assert

                Assert.Single(listQuery.Result);
            }
        }
 public KeyboardRepository(MechKeyboardBaseDbContext context)
 {
     _context = context;
 }