public void SetUserPreference_ShouldCallDataService_WhenNoError() { // Arrange var userPreference = new UserPreferenceBuilder().Build(); mockDataService.Setup(ds => ds.SetUserPreference( userPreference.PortalId, userPreference.UserId, (int) userPreference.MessagesEmailFrequency, (int)userPreference.NotificationsEmailFrequency)).Verifiable(); //Act userPrefencesController.SetUserPreference(userPreference); // Assert mockDataService.Verify(ds => ds.SetUserPreference( userPreference.PortalId, userPreference.UserId, (int)userPreference.MessagesEmailFrequency, (int)userPreference.NotificationsEmailFrequency), Times.Once); }
public void GetUserPreference_ShouldReturnUserPreference_WhenUserHasPreference() { // Arrange var expectedUserPreference = new UserPreferenceBuilder() .WithUserId(Constants.UserID_User12) .WithPortalId(Constants.PORTAL_ValidPortalId) .Build(); var user = GetValidUser(); mockDataService.Setup(ds => ds.GetUserPreference(Constants.PORTAL_ValidPortalId,Constants.UserID_User12)) .Returns(UserPreferenceDataReaderMockHelper.CreateUserPreferenceReader(expectedUserPreference)); //Act var userPreference = userPrefencesController.GetUserPreference(user); // Assert Assert.IsNotNull(userPreference); Assert.AreEqual(expectedUserPreference.MessagesEmailFrequency, userPreference.MessagesEmailFrequency); Assert.AreEqual(expectedUserPreference.NotificationsEmailFrequency, userPreference.NotificationsEmailFrequency); Assert.AreEqual(user.PortalID, userPreference.PortalId); Assert.AreEqual(user.UserID, userPreference.UserId); }