CQRS.Tests.KeyValueStorage.DocumentDbTests.ObjectsWhoseKeysDifferOnlyByTrailingSpacesTrailingWhiteSpaceCaseAreConsideredTheSameObjectForCompatabilityWithSqlServer C# (CSharp) Method

ObjectsWhoseKeysDifferOnlyByTrailingSpacesTrailingWhiteSpaceCaseAreConsideredTheSameObjectForCompatabilityWithSqlServer() private method

        public void ObjectsWhoseKeysDifferOnlyByTrailingSpacesTrailingWhiteSpaceCaseAreConsideredTheSameObjectForCompatabilityWithSqlServer()
        {
            var store = CreateStore();

            var noWhitespace = new Email("theemail");
            var withWhitespace = new Email(noWhitespace.TheEmail + "  ");

            using (var session = OpenSession(store))
            {
                var uow = new UnitOfWork(new SingleThreadUseGuard());
                uow.AddParticipant((IUnitOfWorkParticipant)session);

                session.Save(noWhitespace.TheEmail, noWhitespace);
                Assert.Throws<AttemptToSaveAlreadyPersistedValueException>(() => session.Save(withWhitespace.TheEmail, withWhitespace));

                session.Get<Email>(noWhitespace.TheEmail).Should().Be(session.Get<Email>(withWhitespace.TheEmail));

                uow.Commit();
            }

            using (var session = OpenSession(store))
            {
                var uow = new UnitOfWork(new SingleThreadUseGuard());
                uow.AddParticipant((IUnitOfWorkParticipant)session);

                Assert.Throws<AttemptToSaveAlreadyPersistedValueException>(() => session.Save(withWhitespace.TheEmail, withWhitespace));
                session.Get<Email>(withWhitespace.TheEmail).TheEmail.Should().Be(noWhitespace.TheEmail);
                session.Get<Email>(noWhitespace.TheEmail).Should().Be(session.Get<Email>(withWhitespace.TheEmail));

                session.Delete<Email>(withWhitespace.TheEmail);
                Assert.Throws<NoSuchDocumentException>(() => session.Delete<Email>(withWhitespace.TheEmail));
                Assert.Throws<NoSuchDocumentException>(() => session.Delete<Email>(noWhitespace.TheEmail));


                uow.Commit();
            }
        }
DocumentDbTests