public void WhenAddingMultipeAccounts_TheyShouldBeAdded() { // Given var fakeCiphertextDto1 = CiphertextFakeDataGenerator.GetFakeCiphertextDto1(); var fakeCiphertextDto2 = CiphertextFakeDataGenerator.GetFakeCiphertextDto2(); var fakeCiphertextDtoNotYetAdded = CiphertextFakeDataGenerator.GetFakeCiphertextDtoNotYetAdded(); var ciphertextDatastore = CreateEmpty(); // When ciphertextDatastore.Save(fakeCiphertextDto1); ciphertextDatastore.Save(fakeCiphertextDto2); // Then fakeCiphertextDtoNotYetAdded.Id .Should().BeEmpty(); ciphertextDatastore.GetAll(CiphertextStatus.Any) .Should().HaveCount(2); ciphertextDatastore.GetAll(CiphertextStatus.Deleted) .Should().HaveCount(0); ciphertextDatastore.GetAll(CiphertextStatus.Active) .Should().HaveCount(2); VerifyThatStoredDataMatches(ciphertextDatastore, fakeCiphertextDto1); VerifyThatStoredDataMatches(ciphertextDatastore, fakeCiphertextDto2); }
protected override CiphertextDatastoreBase CreatePopulatedWithFakeData() { var jsonCiphertextDatastore = CreateEmpty(); CiphertextFakeDataGenerator.Populate(jsonCiphertextDatastore); return(jsonCiphertextDatastore); }
public void WhenDeletingAnAccountThatHasBeenAddedToAnEmptyDatastore_ItShouldBeDeleted() { // Given var fakeCiphertextDto1 = CiphertextFakeDataGenerator.GetFakeCiphertextDto1(); var ciphertextDatastore = CreateEmpty(); // When ciphertextDatastore.Save(fakeCiphertextDto1); ciphertextDatastore.Delete(fakeCiphertextDto1.Id); // Then ciphertextDatastore.GetAll(CiphertextStatus.Active) .Should().NotContain(account => account.Id == fakeCiphertextDto1.Id); ciphertextDatastore.GetAll(CiphertextStatus.Deleted) .Should().Contain(account => account.Id == fakeCiphertextDto1.Id); ciphertextDatastore.GetAllIds() .Should().HaveCount(1); // Because AllIds return also deleted ones ciphertextDatastore.GetAll(CiphertextStatus.Active).Count() .Should().BeLessThan(ciphertextDatastore.GetAll(CiphertextStatus.Any).Count()); ciphertextDatastore.Get(fakeCiphertextDto1.Id).Id .Should().NotBeEmpty(); ciphertextDatastore.Get(fakeCiphertextDto1.Id).Ciphertext .Should().BeEmpty(); ciphertextDatastore.Get(fakeCiphertextDto1.Id).Deleted .Should().BeTrue(); ciphertextDatastore.Get(fakeCiphertextDto1.Id).InitializationVector .Should().BeEmpty(); ciphertextDatastore.Get(fakeCiphertextDto1.Id).Salt .Should().BeEmpty(); ciphertextDatastore.Get(fakeCiphertextDto1.Id).IsNew() .Should().BeFalse(); }
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); }