コード例 #1
0
        public void GetAllByMarkId_ShouldReturnEmptyArray_WhenWrongDepartmentId()
        {
            // Arrange
            var context = GetContext(TestData.employees);
            var repo    = new SqlEmployeeRepo(context);

            // Act
            var employees = repo.GetAllByDepartmentId(999);

            // Assert
            Assert.Empty(employees);

            context.Database.EnsureDeleted();
            context.Dispose();
        }
コード例 #2
0
        public void GetAllByDepartmentId_ShouldReturnEmployees()
        {
            // Arrange
            var context = GetContext(TestData.employees);
            var repo    = new SqlEmployeeRepo(context);

            var departmentId = _rnd.Next(1, TestData.departments.Count());

            // Act
            var employees = repo.GetAllByDepartmentId(departmentId);

            // Assert
            Assert.Equal(TestData.employees.Where(
                             v => v.Department.Id == departmentId), employees);

            context.Database.EnsureDeleted();
            context.Dispose();
        }