public void Exist_ReturnsFalse() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; using (var dbContext = new ApplicationDbContext(options)) { var employeesService = new EmployeesService(dbContext); var result = employeesService.Exists("asfalsfha"); Assert.False(result); } }
public void Exist_ReturnsTrue() { 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 result = employeesService.Exists(employee.Id); Assert.True(result); } }