public async Task GetCurrentUserAsync_Registered_ReturnsUser() { var identityProvider = new Mock<IIdentityProvider>(); identityProvider .Setup(ip => ip.CurrentIdentity) .Returns(GetIdentity()); var user = new User(); var userService = new Mock<IUserService>(); userService .Setup(us => us.GetAndUpdateCurrentUserAsync()) .ReturnsAsync(user); var userProvider = new UserProvider(userService.Object, identityProvider.Object); var currentUser = await userProvider.GetCurrentUserAsync(); Assert.Equal(user, currentUser); }
public async Task GetCurrentUserAsync_Unregistered_ReturnsNull() { var identityProvider = new Mock<IIdentityProvider>(); var user = new User(); var userService = new Mock<IUserService>(); userService .Setup(us => us.GetAndUpdateCurrentUserAsync()) .ReturnsAsync(null); var userProvider = new UserProvider(userService.Object, identityProvider.Object); var currentUser = await userProvider.GetCurrentUserAsync(); Assert.Null(currentUser); }