Ejemplo n.º 1
0
        public static void Upsert_Should_Throws_Exception_When_Document_Is_Null()
        {
            // arrange
            var mongoClient = FakeMongoClient.GetMongoClientMock <GenericTestWithBsonIdAnnotation>(true).Object;
            var mongoCRUD   = new MongoCRUD <GenericTestWithBsonIdAnnotation>(mongoClient, "SomeDB");
            GenericTestWithBsonIdAnnotation document = null;

            // act
            Exception ex =
                Assert.Throws <ArgumentNullException>(() => mongoCRUD.Upsert(document));

            // assert
            Assert.Equal("Value cannot be null.\r\nParameter name: document", ex.Message);
        }
Ejemplo n.º 2
0
        public static void Upsert_Should_Works()
        {
            // arrange
            var mongoClient = FakeMongoClient.GetMongoClientMock <GenericTestWithBsonIdAnnotation>(true).Object;
            var mongoCRUD   = new MongoCRUD <GenericTestWithBsonIdAnnotation>(mongoClient, "SomeDB");
            var document    = new GenericTestWithBsonIdAnnotation
            {
                CustomId = "123",
                SomeTest = "test"
            };

            // act
            var isAcknowledged = mongoCRUD.Upsert(document);

            // assert
            Assert.True(isAcknowledged);
        }