Beispiel #1
0
 public void SaveConnectionId_WhenDataIsValid_ShouldUpdataConnectionId()
 {
     Mock<IUowData> mock = new Mock<IUowData>();
     User updatedUser = new User();
     UserService userService = new UserService(mock.Object);
     mock.Setup(g => g.Users.GetAll()).Returns(new User[]
     {
         new User { SessionKey = "100431CZhiZTwwJAh8VTo559HfIyYf8lXyq74Bi2UkBP64ZoLL" },
     }.AsQueryable());
     mock.Setup(u => u.Users.Update(It.IsAny<User>())).Callback((User user) => updatedUser = user);
     userService.SaveConnectionId("100431CZhiZTwwJAh8VTo559HfIyYf8lXyq74Bi2UkBP64ZoLL", "1234");
     Assert.AreEqual("1234",updatedUser.ConnectionId );
 }
Beispiel #2
0
 public void SaveConnectionId_WhenSessionKeyIsInvalid_ShouldThrowException()
 {
     UserService userService = new UserService(mock.Object);
     userService.SaveConnectionId("InvalidSessionKey", "1234");
 }
Beispiel #3
0
 public void SaveConnectionId_WhenConnectionIdIsNull_ShouldThrowException()
 {
     UserService userService = new UserService(mock.Object);
     userService.SaveConnectionId("100431CZhiZTwwJAh8VTo559HfIyYf8lXyq74Bi2UkBP64ZoLL", null);
 }