Ejemplo n.º 1
0
        public void Edit_Negative_Test_Post_Test()
        {
            //Arrange
            var controller = DependencyHelper.GetInstance <EmployeesController>();
            var employee   = TestDataHelper.CreateEmployeeWithValidData(1);

            employee.Address.AddressLine = "2, ABC Road";
            controller.FireValidationForModel(employee);
            //Act
            controller.Edit(employee);

            //Assert
            Assert.IsTrue(EmployeeAddressMustBeUnique.IsErrorAvalilableIn(controller, employee));
        }
        public void Edit_Negative_Test_Post_Mock_Test()
        {
            //Arrange
            _employee    = TestDataHelper.CreateEmployeeWithValidData();
            _employee.Id = 100;
            _fakeEmployeeDbSet.Add(_employee);

            _employee    = TestDataHelper.CreateEmployeeWithValidData();
            _employee.Id = 200;
            _fakeEmployeeDbSet.Add(_employee);

            _mockDbContext.Setup(db => db.EmployeeRepository).Returns(_fakeEmployeeDbSet);

            //Act
            _employeeController.Validate(_employee);

            //Assert
            Assert.True(EmployeeAddressMustBeUnique.IsErrorAvalilableIn(_employeeController, _employee));
        }
Ejemplo n.º 3
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            yield return(EmployeeAddressMustBeUnique.Validate(this));

            yield return(SupervisorCountryMustBeSame.Validate(this));
        }