示例#1
0
        public async void CreateAsync_BumpsUserAccountRevisionDate(Cipher cipher, User user,
                                                                   CipherCompare equalityComparer, List <EfRepo.CipherRepository> suts, List <EfRepo.UserRepository> efUserRepos,
                                                                   SqlRepo.CipherRepository sqlCipherRepo, SqlRepo.UserRepository sqlUserRepo)
        {
            var bumpedUsers = new List <User>();

            foreach (var sut in suts)
            {
                var i = suts.IndexOf(sut);

                var efUser = await efUserRepos[i].CreateAsync(user);
                efUserRepos[i].ClearChangeTracking();
                cipher.UserId         = efUser.Id;
                cipher.OrganizationId = null;

                var postEfCipher = await sut.CreateAsync(cipher);

                sut.ClearChangeTracking();

                var bumpedUser = await efUserRepos[i].GetByIdAsync(efUser.Id);
                bumpedUsers.Add(bumpedUser);
            }

            Assert.True(bumpedUsers.All(u => u.AccountRevisionDate.ToShortDateString() == DateTime.UtcNow.ToShortDateString()));
        }
示例#2
0
        public async void CreateAsync_Works_DataMatches(Cipher cipher, User user, Organization org,
                                                        CipherCompare equalityComparer, List <EfRepo.CipherRepository> suts, List <EfRepo.UserRepository> efUserRepos,
                                                        List <EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.CipherRepository sqlCipherRepo,
                                                        SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrgRepo)
        {
            var savedCiphers = new List <Cipher>();

            foreach (var sut in suts)
            {
                var i = suts.IndexOf(sut);

                var efUser = await efUserRepos[i].CreateAsync(user);
                sut.ClearChangeTracking();
                cipher.UserId = efUser.Id;

                if (cipher.OrganizationId.HasValue)
                {
                    var efOrg = await efOrgRepos[i].CreateAsync(org);
                    sut.ClearChangeTracking();
                    cipher.OrganizationId = efOrg.Id;
                }

                var postEfCipher = await sut.CreateAsync(cipher);

                sut.ClearChangeTracking();

                var savedCipher = await sut.GetByIdAsync(postEfCipher.Id);

                savedCiphers.Add(savedCipher);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            cipher.UserId = sqlUser.Id;

            if (cipher.OrganizationId.HasValue)
            {
                var sqlOrg = await sqlOrgRepo.CreateAsync(org);

                cipher.OrganizationId = sqlOrg.Id;
            }

            var sqlCipher = await sqlCipherRepo.CreateAsync(cipher);

            var savedSqlCipher = await sqlCipherRepo.GetByIdAsync(sqlCipher.Id);

            savedCiphers.Add(savedSqlCipher);

            var distinctItems = savedCiphers.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }