public async Task Get_Friends_As_Existing_User_With_Friend() { // Arrange var expectedID = "123"; var expectedName = "My Friend"; var user = new AuthenticatedUser() { Name = "abc", PreferredUsername = "******", UserIdentifier = "u", ProviderIdentifier = "p" }; await _context.UpsertAsync(TableNames.Users, new UserEntity() { PartitionKey = "u", RowKey = "p", UserID = "user123" }); await _context.UpsertAsync(TableNames.UserFriends, new UserFriendEntity() { PartitionKey = "user123", RowKey = "123", Name = "My Friend" }); // Act var actual = await _friendsHandler.GetFriendAsync(user, "123"); // Assert Assert.NotNull(actual); Assert.Equal(expectedID, actual?.ID); Assert.Equal(expectedName, actual?.Name); }
public async Task Get_Settings_As_Existing_User_With_Notification() { // Arrange var expectedNotifications = 1; var expectedPlayAlwaysUp = true; var user = new AuthenticatedUser() { Name = "abc", PreferredUsername = "******", UserIdentifier = "u", ProviderIdentifier = "p" }; await _context.UpsertAsync(TableNames.Users, new UserEntity() { PartitionKey = "u", RowKey = "p", UserID = "user123" }); await _context.UpsertAsync(TableNames.UserSettings, new UserSettingEntity() { PartitionKey = "user123", RowKey = "user123", PlayAlwaysUp = true }); await _context.UpsertAsync(TableNames.UserNotifications, new UserNotificationEntity() { PartitionKey = "user123", RowKey = "user123", Name = "Browser" }); // Act var actual = await _settingsHandler.GetSettingsAsync(user); // Assert Assert.NotNull(actual); Assert.Equal(expectedNotifications, actual.Notifications.Count); Assert.Equal(expectedPlayAlwaysUp, actual.PlayAlwaysUp); }
public async Task Login() { // Arrange var expectedUserID = "user123"; var user = new AuthenticatedUser() { UserIdentifier = "u", ProviderIdentifier = "p" }; await _context.UpsertAsync(TableNames.Users, new UserEntity() { PartitionKey = "u", RowKey = "p", UserID = "user123" }); // Act var actual = await _meHandler.LoginAsync(user); // Assert Assert.Equal(expectedUserID, actual.ID); }
public async Task Get_Games_As_Existing_User_With_Game() { // Arrange var expected = "123"; var user = new AuthenticatedUser() { Name = "abc", PreferredUsername = "******", UserIdentifier = "u", ProviderIdentifier = "p" }; var compactor = new Compactor(); await _context.UpsertAsync(TableNames.Users, new UserEntity() { PartitionKey = "u", RowKey = "p", UserID = "user123" }); await _context.UpsertAsync(TableNames.GamesWaitingForYou, new GameEntity() { PartitionKey = "user123", RowKey = "123", Data = compactor.Compact(new MyChessGame() { ID = "123" }) }); // Act var actual = await _gamesHandler.GetGameAsync(user, "123", null); // Assert Assert.NotNull(actual); Assert.Equal(expected, actual?.ID); }