public async Task AddFollowerAsync_WithValidData_ShouldAddFollowerToDatabase() { // Arrange var context = InMemoryDbContext.Initiliaze(); var userRepository = new EfDeletableEntityRepository <ApplicationUser>(context); var userFollowerRepository = new EfRepository <UserFollower>(context); var profileService = new ProfilesService(userRepository, userFollowerRepository); await this.SeedUsers(context); var model = new AddFollowerModel { UserId = "userOneId", FollowerId = "userTwoId", }; // Act int expectedCount = userFollowerRepository.All().Count() + 1; await profileService.AddFollowerAsync(model); int actualCount = userFollowerRepository.All().Count(); // Assert Assert.Equal(expectedCount, actualCount); }
public async Task AddFollowerAsync_WithValidData_ShouldReturnTrue() { // Arrange var context = InMemoryDbContext.Initiliaze(); var userRepository = new EfDeletableEntityRepository <ApplicationUser>(context); var userFollowerRepository = new EfRepository <UserFollower>(context); var profileService = new ProfilesService(userRepository, userFollowerRepository); await this.SeedUsers(context); var model = new AddFollowerModel { UserId = "userOneId", FollowerId = "userTwoId", }; // Act bool actualResult = await profileService.AddFollowerAsync(model); // Assert Assert.True(actualResult); }