示例#1
0
        private void VerifyThatStoredDataMatches(CiphertextDatastoreBase ciphertextDatastore,
                                                 CiphertextDto CiphertextDto)
        {
            var accountId = CiphertextDto.Id;

            ciphertextDatastore.GetAllIds()
            .Should().Contain(id => id.Equals(accountId));

            ciphertextDatastore.GetAll()
            .Should().Contain(datastoreCiphertextDto => accountId == datastoreCiphertextDto.Id);

            ciphertextDatastore.Get(accountId).Equals(CiphertextDto)
            .Should().BeTrue();

            ciphertextDatastore.Get(accountId).Deleted
            .Should().Be(CiphertextDto.Deleted);

            ciphertextDatastore.Get(accountId).Id
            .Should().Be(CiphertextDto.Id);

            ciphertextDatastore.Get(accountId).Ciphertext
            .Should().Equal(CiphertextDto.Ciphertext);

            ciphertextDatastore.Get(accountId).InitializationVector
            .Should().Equal(CiphertextDto.InitializationVector);

            ciphertextDatastore.Get(accountId).Salt
            .Should().Equal(CiphertextDto.Salt);
        }
示例#2
0
        private void WhenAddingASingleAccountToADataStore_ItShouldBeAdded(CiphertextDatastoreBase ciphertextDatastore, int expectedCount)
        {
            // Given
            var fakeCiphertextDto = CiphertextFakeDataGenerator.GetFakeCiphertextDtoNotYetAdded();

            // When
            ciphertextDatastore.Save(fakeCiphertextDto);

            // Then
            ciphertextDatastore.GetAllIds()
            .Should().HaveCount(expectedCount);

            ciphertextDatastore.GetAll(CiphertextStatus.Any)
            .Should().HaveCount(expectedCount);

            ciphertextDatastore.GetAll(CiphertextStatus.Active)
            .Should().HaveCount(expectedCount);

            ciphertextDatastore.GetAll(CiphertextStatus.Deleted)
            .Should().HaveCount(0);

            VerifyThatStoredDataMatches(ciphertextDatastore, fakeCiphertextDto);
        }
        private void VerifyThatStoredDataMatches(CiphertextDatastoreBase ciphertextDatastore,
                                                             CiphertextDto CiphertextDto)
        {
            var accountId = CiphertextDto.Id;
            ciphertextDatastore.GetAllIds()
                               .Should().Contain(id => id.Equals(accountId));

            ciphertextDatastore.GetAll()
                               .Should().Contain(datastoreCiphertextDto => accountId == datastoreCiphertextDto.Id);

            ciphertextDatastore.Get(accountId).Equals(CiphertextDto)
                               .Should().BeTrue();

            ciphertextDatastore.Get(accountId).Deleted
                               .Should().Be(CiphertextDto.Deleted);

            ciphertextDatastore.Get(accountId).Id
                               .Should().Be(CiphertextDto.Id);

            ciphertextDatastore.Get(accountId).Ciphertext
                               .Should().Equal(CiphertextDto.Ciphertext);

            ciphertextDatastore.Get(accountId).InitializationVector
                               .Should().Equal(CiphertextDto.InitializationVector);

            ciphertextDatastore.Get(accountId).Salt
                               .Should().Equal(CiphertextDto.Salt);
        }
        private void WhenAddingASingleAccountToADataStore_ItShouldBeAdded(CiphertextDatastoreBase ciphertextDatastore, int expectedCount)
        {
            // Given
            var fakeCiphertextDto = CiphertextFakeDataGenerator.GetFakeCiphertextDtoNotYetAdded();

            // When
            ciphertextDatastore.Save(fakeCiphertextDto);

            // Then
            ciphertextDatastore.GetAllIds()
                               .Should().HaveCount(expectedCount);

            ciphertextDatastore.GetAll(CiphertextStatus.Any)
                               .Should().HaveCount(expectedCount);

            ciphertextDatastore.GetAll(CiphertextStatus.Active)
                               .Should().HaveCount(expectedCount);

            ciphertextDatastore.GetAll(CiphertextStatus.Deleted)
                               .Should().HaveCount(0);

            VerifyThatStoredDataMatches(ciphertextDatastore, fakeCiphertextDto);
        }
示例#5
0
 public static void Populate(CiphertextDatastoreBase jsonCiphertextDatastore)
 {
     jsonCiphertextDatastore.Save(GetFakeCiphertextDto1());
     jsonCiphertextDatastore.Save(GetFakeCiphertextDto2());
 }