public void Insert_TypedDocumentWithAssignedId_IsStored()
        {
            var document = new PersonWithId { _id = SimoId.NewId(), Name = "Daniel" };

            using (var session = new SimoSession(TestHelper.CreateConnection()))
            {
                session[DbName][PersonsCollectionName].Insert(document);
            }

            var numOfDocs = TestHelper.GetDocumentCount(new { document._id }, Constants.Collections.PersonsCollectionName);
            Assert.AreEqual(1, numOfDocs);
        }
        public void InsertSingle_TypedDocumentWithAssignedId_IsStored()
        {
            var person2Insert = new PersonWithId { _id = SimoId.NewId(), Name = "Daniel", Age = 29 };

            using (var cn = TestHelper.CreateConnection())
            {
                var insertCommand = new InsertDocumentsCommand(cn)
                                    {
                                        FullCollectionName = Constants.Collections.PersonsFullCollectionName,
                                        Documents = new[] { person2Insert }
                                    };
                insertCommand.Execute();
            }

            var refetched = TestHelper.GetDocument<PersonWithId>(person2Insert, Constants.Collections.PersonsCollectionName);
            Assert.AreEqual(person2Insert._id, refetched._id);
        }
        public void InsertSingle_TypedDocumentWithEmptyAssignedId_ThrowsException()
        {
            var person2Insert = new PersonWithId { _id = SimoId.Empty, Name = "Daniel", Age = 29 };

            using (var cn = TestHelper.CreateConnection())
            {
                var insertCommand = new InsertDocumentsCommand(cn)
                                    {
                                        FullCollectionName = Constants.Collections.PersonsFullCollectionName,
                                        Documents = new[] { person2Insert }
                                    };

                insertCommand.Execute();
            }

            Assert.Fail("Should not have been able to insert document with Empty ObjectId.");
        }