public void CallsEmployeeServiceUpdateMethod() { // Arrange var claims = Fixture.Create <Dictionary <string, string> >(); // Act SystemUnderTest.Post("eKey1", claims); // Assert MockEmployeesService.Verify(m => m.UpdateEmployee(It.IsAny <IUpdateEmployeeParameters>()), Times.Once()); }
public void CallsEmployeeService_GetEmployeeDetails_WithIdParameter() { // Arrange const string employeeKey = "ekey1"; var claims = Fixture.Create <Dictionary <string, string> >(); // Act SystemUnderTest.Post(employeeKey, claims); // Assert MockEmployeesService.Verify(m => m.GetEmployeeDetailsByKey(employeeKey), Times.Once()); }
public new void Setup() { _employee = Fixture.Create <TestableEmployeeDetailsReturn>(); MockEmployeesService.Setup(m => m.GetEmployeeDetailsByKey(It.IsAny <string>())) .Returns((string key) => { _employee.EmployeeKey = key; return(new SuccessResult <IEmployeeDetailsReturn>(_employee)); }); MockEmployeesService.Setup(m => m.UpdateEmployee(It.IsAny <IUpdateEmployeeParameters>())) .Returns(new SuccessResult()); }
public void CallsCreateEmployee_IfEmployeeKeyIsEmpty() { // Arrange MockEmployeesService.Setup(m => m.CreateEmployee(It.IsAny <ICreateEmployeeParameters>())) .Returns(new SuccessResult <string>()); RegisterParameters.EmployeeKey = string.Empty; // Act var result = SystemUnderTest.Register(RegisterParameters); // Assert MockEmployeesService.Verify(m => m.CreateEmployee(It.IsAny <ICreateEmployeeParameters>()), Times.Once()); }
public void Returns500OnFailureResult() { // Arrange const string id = "key1"; var claims = Fixture.Create <Dictionary <string, string> >(); MockEmployeesService.Setup(m => m.UpdateEmployee(It.IsAny <IUpdateEmployeeParameters>())) .Returns(new FailureResult()); // Act var response = SystemUnderTest.Post(id, claims); // Assert Assert.AreEqual(HttpStatusCode.InternalServerError, response.StatusCode); }
public void Returns500IfGetEmployeeDetailsByKeyReturnsFailure() { // Arrange const string employeeKey = "ekey1"; MockEmployeesService.Setup(m => m.GetEmployeeDetailsByKey(employeeKey)) .Returns(new FailureResult <IEmployeeDetailsReturn>()); var claims = Fixture.Create <Dictionary <string, string> >(); // Act var result = SystemUnderTest.Post(employeeKey, claims); // Assert Assert.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode); }
public new void Setup() { base.Setup(); EmployeeDetailsReturned = null; RegisterParameters = Fixture.Create <RegisterModel>(); MockEmployeesService.Setup(m => m.ActivateEmployee(It.IsAny <IActivateEmployeeParameters>())) .Returns(new SuccessResult()); MockEmployeesService.Setup(m => m.GetEmployeeDetailsByUserName(RegisterParameters.UserName)) .Returns(new SuccessResult <TestableEmployeeDetailsReturn>( Fixture.Build <TestableEmployeeDetailsReturn>() .With(m => m.EmployeeKey, RegisterParameters.EmployeeKey) .Create() )); }
public void ReturnsViewResultInInvalidState_IfEmployeeKeyProvidedIsInvalid() { // Arrange MockEmployeesService.Setup(m => m.GetEmployeeDetailsByUserName(RegisterParameters.UserName)) .Returns(new InvalidResult <IEmployeeDetailsReturn>()); // Act var result = SystemUnderTest.Register(RegisterParameters) as ViewResult; // Assert Assert.IsNotNull(result); Assert.AreEqual(MVC.Security.Views.Register, result.ViewName); Assert.IsFalse(SystemUnderTest.ModelState.IsValid); MockEmployeesService.Verify( m => m.ActivateEmployee(It.IsAny <IActivateEmployeeParameters>()), Times.Never()); }
public void SetsEmployeeEmailAddress_IfEmployeeKeyIsProvided() { // Arrange IActivateEmployeeParameters actualUpdateValues = null; MockEmployeesService.Setup(m => m.ActivateEmployee(It.IsAny <IActivateEmployeeParameters>())) .Callback((IActivateEmployeeParameters input) => actualUpdateValues = input) .Returns(new SuccessResult()); // Act SystemUnderTest.Register(RegisterParameters); // Assert Assert.IsNotNull(actualUpdateValues); Assert.AreEqual(RegisterParameters.Email, actualUpdateValues.EmailAddress); MockEmployeesService.Verify(m => m.ActivateEmployee(It.IsAny <IActivateEmployeeParameters>()), Times.Once()); }
public void CallsEmployeeServiceUpdateMethodWithExpectedParameters() { // Arrange const string employeeKey = "ekey1"; var claims = Fixture.Create <Dictionary <string, string> >(); IUpdateEmployeeParameters actualValues = null; MockEmployeesService.Setup(m => m.UpdateEmployee(It.IsAny <IUpdateEmployeeParameters>())) .Callback((IUpdateEmployeeParameters input) => actualValues = input) .Returns(new SuccessResult()); // Act SystemUnderTest.Post(employeeKey, claims); // Assert Assert.AreEqual(employeeKey, actualValues.EmployeeKey); Assert.AreEqual(claims, actualValues.Claims); }
public void ReturnsViewResultInInvalidState_IfUserNameIsInvalidForEmployeeKey() { // Arrange RegisterParameters.EmployeeKey = "InvalidEmployeeKey"; // Act var result = SystemUnderTest.Register(RegisterParameters) as ViewResult; // Assert Assert.IsNotNull(result); Assert.AreEqual(MVC.Security.Views.Register, result.ViewName); Assert.IsFalse(SystemUnderTest.ModelState.IsValid); MockEmployeesService.Verify( m => m.GetEmployeeDetailsByUserName(RegisterParameters.UserName), Times.Once()); MockEmployeesService.Verify( m => m.CreateEmployee(It.IsAny <ICreateEmployeeParameters>()), Times.Never()); }
public void ReturnsViewResultInInvalidState_IfEmployeeKeyIsEmptyAndServiceResultIsUnsuccessful() { // Arrange MockEmployeesService.Setup(m => m.CreateEmployee(It.IsAny <ICreateEmployeeParameters>())) .Returns(new FailureResult <string>()); RegisterParameters.EmployeeKey = string.Empty; // Act var result = SystemUnderTest.Register(RegisterParameters) as ViewResult; // Assert Assert.IsNotNull(result); Assert.AreEqual(MVC.Security.Views.Register, result.ViewName); Assert.IsFalse(SystemUnderTest.ModelState.IsValid); MockEmployeesService.Verify( m => m.CreateEmployee(It.IsAny <ICreateEmployeeParameters>()), Times.Once()); }
public void OnlyClaimsEmployeePropertyIsChanged() { // Arrange const string employeeKey = "ekey1"; var claims = Fixture.Create <Dictionary <string, string> >(); IUpdateEmployeeParameters actualValues = null; MockEmployeesService.Setup(m => m.UpdateEmployee(It.IsAny <IUpdateEmployeeParameters>())) .Callback((IUpdateEmployeeParameters input) => actualValues = input) .Returns(new SuccessResult()); // Act SystemUnderTest.Post(employeeKey, claims); // Assert Assert.AreEqual(_employee.EmployeeKey, actualValues.EmployeeKey); Assert.AreEqual(_employee.DisplayName, actualValues.DisplayName); Assert.AreEqual(_employee.EmailAddress, actualValues.EmailAddress); Assert.AreEqual(_employee.UserName, actualValues.UserName); }