public bool Equals(UserProfile other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Username, Username) && Equals(other.Address, Address); }
public void Create_TestSuccess() { var userServiceMock = new Mock<IUserService>(); var userService = userServiceMock.Object; var userProfileServiceMock = new Mock<IUserProfileService>(); var userProfileService = userProfileServiceMock.Object; var controllerContextMock = new Mock<ControllerContext>(); var userController = new UserController(userService, userProfileService); userController.ControllerContext = controllerContextMock.Object; var createModel = new CreateViewModel { Username = "******", Password = "******", StreetAddress = "rofl", City = "mao", ZipCode = 1000 }; var credentials = new UserCredentials() { Email = createModel.Email, Password = createModel.Password }; var accessToken = new UserAccessToken("123456"); userServiceMock.Setup(a => a.Create(credentials)).Returns(accessToken); userServiceMock.Setup(a => a.Login(credentials)).Returns(accessToken); var viewResult = userController.Index(createModel) as RedirectToRouteResult; Assert.IsNotNull(viewResult, "Controller did not return a RedirectToRouteResult"); var userProfile = new UserProfile() { Username = createModel.Username, Address = new Address() { Street = createModel.StreetAddress, City = createModel.City, ZipCode = createModel.ZipCode } }; userServiceMock.Verify(a => a.Create(credentials)); userProfileServiceMock.Verify(a => a.UpdateProfile(accessToken, userProfile)); }