public async Task AccountDeletionWorks(string nickname, string password) { await userContext.CreateUser(authenticationService, nickname, password); var exception = await Assert.ThrowsAsync <DatesException>(async() => { await authenticationService.DeleteAccount(password); await authenticationService.SignIn(nickname, password); }); Assert.Equal("No such user was found", exception.Message); }
public async Task DateCreationWorks() { const int eventId = 100; await firstContext.CreateUser(firstAuth); var groupId = await firstGroups.UpsertGroup(DefaultGroup()); await firstDates.Create(groupId, eventId); var dates = await firstDates.List(groupId); Assert.Single(dates); Assert.Equal(groupId, dates[0].GroupId); Assert.Equal(eventId, dates[0].EventId); }
public async Task UpdatingFailsWhenUserDoesNotOwnAGroup() { await firstContext.CreateUser(firstAuth); await secondContext.CreateUser(secondAuth, "SecondFellow"); var groupId = await firstGroups.UpsertGroup(DefaultGroup()); var exception = await Assert.ThrowsAsync <DatesException>(async() => { await secondGroups.UpsertGroup(DefaultGroup(groupId)); }); Assert.Equal("You do not own this group. No permission for editing", exception.Message); }
public async Task FavoritesWork() { await firstContext.CreateUser(firstAuth); await secondContext.CreateUser(secondAuth, "SecondFellow"); var firstState = await firstFavoriteUsers.List(); await firstFavoriteUsers.Add(secondContext.UserId); var secondState = await firstFavoriteUsers.List(); await firstFavoriteUsers.Remove(secondContext.UserId); var thirdState = await firstFavoriteUsers.List(); Assert.Empty(firstState); Assert.Single(secondState); Assert.Contains(secondContext.UserId, secondState.Select(x => x.Id)); Assert.Empty(thirdState); }
public async Task DatesListingIsSuppressedForNonMember() { await firstContext.CreateUser(firstAuth); await secondContext.CreateUser(secondAuth, "Second"); var groupId = await firstGroups.UpsertGroup(DefaultGroup()); await firstDates.Create(groupId, 100); await firstDates.Create(groupId, 101); await firstDates.Create(groupId, 102); var dates = await secondDates.List(groupId); Assert.Empty(dates); }
public async Task EventsOperationsWork() { await context.CreateUser(auth); var first = await events.List(); await events.Add(1); var second = await events.List(); await events.Remove(1); await events.Remove(2); var third = await events.List(); Assert.Empty(first); Assert.Equal(new List <int> { 1 }, second); Assert.Empty(third); }
public async Task SearchWorks() { var dbContextFactory = new InMemoryDbContextFactory(); var firstUser = new TestUserContext(); await firstUser.CreateUser(new AuthenticationService(firstUser, dbContextFactory), Nicknames[0]); foreach (var nickname in Nicknames.Skip(1)) { var userContext = new TestUserContext(); await userContext.CreateUser(new AuthenticationService(userContext, dbContextFactory), nickname); } var personsService = new PersonsService(firstUser, dbContextFactory); var persons = await personsService.SearchPeopleByNickname("ExP"); Assert.Equal(3, persons.Count); Assert.Equal( new[] { "Expiration", "Explorer", "The Experienced Dude" }, persons.Select(x => x.Nickname).OrderBy(x => x).ToArray() ); }
public async Task InsertionWorks() { const string name = "Dudes"; const string purpose = "Friends parties"; await firstContext.CreateUser(firstAuth); var groupId = await firstGroups.UpsertGroup(new Group { Name = name, Purpose = purpose }); var group = (await firstGroups.List())[0]; Assert.Equal(groupId, group.Id); Assert.Equal(name, group.Name); Assert.Equal(purpose, group.Purpose); }