public async Task AllWithValidId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new EmployeesService(new EfDeletableEntityRepository <Employee>(dbContext));
            var date    = DateTime.UtcNow;

            for (int i = 1; i <= 5; i++)
            {
                await service.AddAsync(
                    "Ivan Ivanov" + i,
                    "*****@*****.**",
                    "08888888888",
                    date,
                    "1");
            }

            var results = service.All <EmployeeViewModel>("1");
            int count   = 0;

            foreach (var result in results)
            {
                count++;
                Assert.Equal("Ivan Ivanov" + count, result.FullName);
                Assert.Equal("*****@*****.**", result.Email);
                Assert.Equal("08888888888", result.PhoneNumber);
                Assert.Equal(date, result.StartWorkDate);
                Assert.Equal("1", result.GamingHallId);
            }

            Assert.Equal(5, count);
            dbContext.Database.EnsureDeleted();
            dbContext.Dispose();
        }
        public async Task AllWithNullId()
        {
            ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>()
                                                                      .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options);
            var service = new EmployeesService(new EfDeletableEntityRepository <Employee>(dbContext));
            var date    = DateTime.UtcNow;

            for (int i = 1; i <= 5; i++)
            {
                await service.AddAsync(
                    "Ivan Ivanov" + i,
                    "*****@*****.**",
                    "08888888888",
                    date,
                    "1");
            }

            var results = service.All <EmployeeViewModel>(null);
            int count   = 0;

            foreach (var result in results)
            {
                count++;
            }

            Assert.Equal(0, count);
            dbContext.Dispose();
        }
        public void All_ReturnsCorrectCollection()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            using (var dbContext = new ApplicationDbContext(options))
            {
                JobPosition jobPosition = new JobPosition()
                {
                    Name = "newJobPos",
                };
                dbContext.JobPositions.Add(jobPosition);
                dbContext.SaveChanges();

                OperatingLocation operatingLocation = new OperatingLocation()
                {
                    Town     = "Sofia",
                    Address  = "test street",
                    ImageUrl = "kgkkkgk",
                };
                dbContext.OperatingLocations.Add(operatingLocation);
                dbContext.SaveChanges();

                Employee employee = new Employee()
                {
                    FirstName           = "Ivan",
                    MiddleName          = "Ivanov",
                    LastName            = "Ivanov",
                    PhoneNumber         = "0897924218",
                    Email               = "*****@*****.**",
                    Town                = "Sofia",
                    Address             = "address 1",
                    ImageUrl            = "aasdfag",
                    OperatingLocationId = operatingLocation.Id,
                    JobPositionId       = jobPosition.Id,
                };

                dbContext.Employees.Add(employee);
                dbContext.SaveChanges();

                var employeesService = new EmployeesService(dbContext);
                var employees        = employeesService.All();

                Assert.Collection(employees, item => Assert.Contains("Ivan", employee.FirstName));
            }
        }