public async Task SetProfileInfoAsync_AffectGetProfileAsync_When_PassingProfileInfo(long userId, ProfileEntriesCollection profileEntries) { await this.subject.SetProfileEntriesCollectionAsync(userId, profileEntries); Profile profile = await this.subject.GetProfileAsync(userId); Assert.AreEqual(profile.Login, this.validLogin); Assert.AreEqual(profile.ProfileEntriesCollection.Count(), profileEntries.Count()); foreach (var entry in profile.ProfileEntriesCollection) { Assert.AreEqual(profileEntries.Where(v => v.Equals(entry)).Count(), 1); } }
public async Task SetProfileInfoAsync_NotAffectGetProfileAsync_For_OtherUsers() { Account account1 = await this.accountRepository.CreateAccountAsync(this.validLogin, this.validPassword); Account account2 = await this.accountRepository.CreateAccountAsync(this.anotherValidLogin, this.anotherValidPassword); var profileEntries1 = new ProfileEntriesCollection { new ProfileEntry { Type = ProfileEntryType.FirstName, Value = "a", IsPublic = false }, new ProfileEntry { Type = ProfileEntryType.LastName, Value = "b", IsPublic = true }, new ProfileEntry { Type = ProfileEntryType.MiddleName, Value = "c", IsPublic = false }, }; var profileEntries2 = new ProfileEntriesCollection { new ProfileEntry { Type = ProfileEntryType.MiddleName, Value = "c", IsPublic = false }, new ProfileEntry { Type = ProfileEntryType.City, Value = "d", IsPublic = true }, new ProfileEntry { Type = ProfileEntryType.Description, Value = "e", IsPublic = false }, }; await this.subject.SetProfileEntriesCollectionAsync(account1.UserId, profileEntries1); await this.subject.SetProfileEntriesCollectionAsync(account2.UserId, profileEntries2); Profile profile1 = await this.subject.GetProfileAsync(account1.UserId); Assert.AreEqual(profile1.Login, this.validLogin); Assert.AreEqual(profile1.ProfileEntriesCollection.Count(), profileEntries1.Count()); foreach (var entry in profile1.ProfileEntriesCollection) { Assert.AreEqual(profileEntries1.Where(v => v.Equals(entry)).Count(), 1); } Profile profile2 = await this.subject.GetProfileAsync(account2.UserId); Assert.AreEqual(profile2.Login, this.anotherValidLogin); Assert.AreEqual(profile2.ProfileEntriesCollection.Count(), profileEntries1.Count()); foreach (var entry in profile2.ProfileEntriesCollection) { Assert.AreEqual(profileEntries2.Where(v => v.Equals(entry)).Count(), 1); } await this.subject.SetProfileEntriesCollectionAsync(account2.UserId, new ProfileEntriesCollection()); profile1 = await this.subject.GetProfileAsync(account1.UserId); Assert.AreEqual(profile1.Login, this.validLogin); Assert.AreEqual(profile1.ProfileEntriesCollection.Count(), profileEntries1.Count()); foreach (var entry in profile1.ProfileEntriesCollection) { Assert.AreEqual(profileEntries1.Where(v => v.Equals(entry)).Count(), 1); } profile2 = await this.subject.GetProfileAsync(account2.UserId); Assert.AreEqual(profile2.Login, this.anotherValidLogin); Assert.AreEqual(profile2.ProfileEntriesCollection.Count(), 0); }