public void TextFeedbackIsEmptyByDefault()
        {
            sut = new Employee(Guid.NewGuid(), "Testaaja", "Teppo", "Devaaja", "Turku", false);

            Assert.IsNotNull(sut.TextFeedback);
            Assert.AreEqual(0, sut.TextFeedback.Count);
        }
        public void TextFeedbackIsInitialized()
        {
            sut = new Employee(Guid.NewGuid(), "Testaaja", "Teppo", "Devaaja", "Turku", false, new List<string> { "Nice", "Good job" });

            Assert.IsNotNull(sut.TextFeedback);
            Assert.AreEqual(2, sut.TextFeedback.Count);
        }
        public void NewEmployeesAreAddedToFeedbackRepository()
        {
            Guid newEmployee1Id = Guid.NewGuid();
            const string newEmployee1LastName = "North";
            const string newEmployee1FirstName = "Peter";
            const string newEmployee1Title = "CIO";
            const string newEmployee1Location = "NY";
            const string newEmployee1Organization = "HR";
            const string newEmployee1SubOrganization = "subHR";
            byte[] newEmployee1Picture = new byte[0];

            Guid newEmployee2Id = Guid.NewGuid();
            const string newEmployee2LastName = "Dean";
            const string newEmployee2FirstName = "James";
            const string newEmployee2Title = "CTO";
            const string newEmployee2Location = "LA";
            const string newEmployee2Organization = "IT";
            const string newEmployee2SubOrganization = "Installing";
            byte[] newEmployee2Picture = new byte[0];

            Guid oldEmployeeId = Guid.NewGuid();
            const string oldEmployeeLastName = "Travolta";
            const string oldEmployeeFirstName = "John";
            const string oldEmployeeTitle = "CFO";
            const string oldEmployeeLocation = "NJ";
            const string oldEmployeeOrganization = "Sanitation";
            const string oldEmployeeSubOrganization = "Vacuum cleaning";
            byte[] oldEmployeePicture = new byte[0];

            feedbackRepository.HasEmployee(newEmployee1Id).Returns(false);
            feedbackRepository.HasEmployee(newEmployee2Id).Returns(false);
            feedbackRepository.HasEmployee(oldEmployeeId).Returns(true);

            IEmployee newEmployee1 = CreateEmployeeMock(newEmployee1Id, newEmployee1LastName, newEmployee1FirstName, newEmployee1Title, newEmployee1Location, newEmployee1Organization, newEmployee1SubOrganization,
                newEmployee1Picture);
            IEmployee newEmployee2 = CreateEmployeeMock(newEmployee2Id, newEmployee2LastName, newEmployee2FirstName, newEmployee2Title, newEmployee2Location, newEmployee2Organization, newEmployee2SubOrganization,
                newEmployee2Picture);
            IEmployee oldEmployee = CreateEmployeeMock(oldEmployeeId, oldEmployeeLastName, oldEmployeeFirstName, oldEmployeeTitle, oldEmployeeLocation, oldEmployeeOrganization, oldEmployeeSubOrganization,
                oldEmployeePicture);
            employeeRepository.GetEmployees().Returns(new List<IEmployee> { newEmployee1, newEmployee2, oldEmployee });

            Employee oldActiveEmployee = new Employee(oldEmployeeId, oldEmployeeLastName, oldEmployeeFirstName, oldEmployeeTitle, oldEmployeeLocation, false, new List<string>());
            feedbackRepository.GetActiveEmployees().Returns(new List<Employee> { oldActiveEmployee });

            sut.Synchronize();

            feedbackRepository.Received(1).AddEmployee(newEmployee1Id, newEmployee1LastName, newEmployee1FirstName, newEmployee1Title, newEmployee1Location, newEmployee1Organization, newEmployee1SubOrganization,
                newEmployee1Picture);
            feedbackRepository.Received(1).AddEmployee(newEmployee2Id, newEmployee2LastName, newEmployee2FirstName, newEmployee2Title, newEmployee2Location, newEmployee2Organization, newEmployee2SubOrganization,
                newEmployee2Picture);
            feedbackRepository.DidNotReceive().AddEmployee(oldEmployeeId, oldEmployeeLastName, oldEmployeeFirstName, oldEmployeeTitle, oldEmployeeLocation, oldEmployeeOrganization, oldEmployeeSubOrganization,
                oldEmployeePicture);
        }
        public void GetEmployees()
        {
            IMapper<Application.Employee, Employee> employeeMapper = CreateEmployeeMapperMock();
            var appEmployee = new Application.Employee(Guid.NewGuid(), "lastName", "firstName", "title", null, false);
            var apiEmployee = new Employee();
            employeeMapper.Map(appEmployee).Returns(apiEmployee);
            repository.GetActiveEmployees().Returns(new List<Application.Employee> { appEmployee });

            var result = sut.GetEmployees() as OkNegotiatedContentResult<IEnumerable<Employee>>;

            Assert.IsNotNull(result);
            Assert.AreSame(apiEmployee, result.Content.Single());
        }
        public void GetEmployee()
        {
            Guid id = Guid.NewGuid();
            IMapper<Application.Employee, Employee> employeeMapper = CreateEmployeeMapperMock();
            var appEmployee = new Application.Employee(id, "lastName", "firstName", "title", null, false);
            var apiEmployee = new Employee();
            employeeMapper.Map(appEmployee).Returns(apiEmployee);
            repository.GetEmployee(id).Returns(appEmployee);

            var result = sut.GetEmployee(id) as OkNegotiatedContentResult<Employee>;

            Assert.IsNotNull(result);
            Assert.AreSame(apiEmployee, result.Content);
        }
 public void FirstNameCannotBeNull()
 {
     sut = new Employee(Guid.NewGuid(), "Testaaja", null, "Devaaja", "Turku", false);
 }
 public void FirstNameCannotBeEmpty()
 {
     sut = new Employee(Guid.NewGuid(), "Testaaja", string.Empty, "Devaaja", "Turku", false);
 }
 public void IdCannotBeEmpty()
 {
     sut = new Employee(Guid.Empty, "Testaaja", "Teppo", "Devaaja", "Turku", false);
 }
        public void RemovedEmployeesAreDeactivatedInFeedbackRepository()
        {
            Guid oldEmployeeId = Guid.NewGuid();
            const string oldEmployeeLastName = "Travolta";
            const string oldEmployeeFirstName = "John";
            const string oldEmployeeTitle = "CFO";
            const string oldEmployeeLocation = "NJ";
            const string oldEmployeeOrganization = "Sanitation";
            const string oldEmployeeSubOrganization = "Cleaning";
            byte[] oldEmployeePicture = new byte[0];

            Guid oldRemovedEmployee1Id = Guid.NewGuid();
            const string oldRemovedEmployee1LastName = "Tyson";
            const string oldRemovedEmployee1FirstName = "Mike";
            const string oldRemovedEmployee1Title = "WBA";
            const string oldRemovedEmployee1Location = "LA";

            Guid oldRemovedEmployee2Id = Guid.NewGuid();
            const string oldRemovedEmployee2LastName = "North";
            const string oldRemovedEmployee2FirstName = "Peter";
            const string oldRemovedEmployee2Title = "P";
            const string oldRemovedEmployee2Location = "NY";

            feedbackRepository.HasEmployee(oldEmployeeId).Returns(true);
            feedbackRepository.HasEmployee(oldRemovedEmployee1Id).Returns(true);
            feedbackRepository.HasEmployee(oldRemovedEmployee2Id).Returns(true);

            IEmployee oldEmployee = CreateEmployeeMock(oldEmployeeId, oldEmployeeLastName, oldEmployeeFirstName, oldEmployeeTitle, oldEmployeeLocation, oldEmployeeOrganization, oldEmployeeSubOrganization, oldEmployeePicture);
            employeeRepository.GetEmployees().Returns(new List<IEmployee> { oldEmployee });

            Employee oldActiveEmployee1 = new Employee(oldEmployeeId, oldEmployeeLastName, oldEmployeeFirstName, oldEmployeeTitle, oldEmployeeLocation, false, new List<string>());
            Employee oldActiveEmployee2 = new Employee(oldRemovedEmployee1Id, oldRemovedEmployee1LastName, oldRemovedEmployee1FirstName, oldRemovedEmployee1Title, oldRemovedEmployee1Location, false, new List<string>());
            Employee oldActiveEmployee3 = new Employee(oldRemovedEmployee2Id, oldRemovedEmployee2LastName, oldRemovedEmployee2FirstName, oldRemovedEmployee2Title, oldRemovedEmployee2Location, false, new List<string>());
            feedbackRepository.GetActiveEmployees().Returns(new List<Employee> { oldActiveEmployee1, oldActiveEmployee2, oldActiveEmployee3 });

            sut.Synchronize();

            feedbackRepository.Received(1).DeactivateEmployee(oldRemovedEmployee1Id);
            feedbackRepository.Received(1).DeactivateEmployee(oldRemovedEmployee1Id);
            feedbackRepository.DidNotReceive().DeactivateEmployee(oldEmployeeId);
        }