Example #1
0
        public static void Create_Many_Should_Works()
        {
            // arrange
            var mongoClient = FakeMongoClient.GetMongoClientMock <GenericTestWithIdProperty>(true).Object;
            var mongoCRUD   = new MongoCRUD <GenericTestWithIdProperty>(mongoClient, "SomeDB");

            var document1 = new GenericTestWithIdProperty
            {
                Id       = "123",
                SomeTest = "test"
            };

            var document2 = new GenericTestWithIdProperty
            {
                Id       = "124",
                SomeTest = "test2"
            };

            var documents = new List <GenericTestWithIdProperty> {
                document1, document2
            };

            // act
            mongoCRUD.Create(documents);

            // assert
            // if no exception, create has success
        }
Example #2
0
        public static void Create_Many_Should_Throws_Exception_When_Document_Is_Null()
        {
            // arrange
            var mongoClient = FakeMongoClient.GetMongoClientMock <GenericTestWithIdProperty>(true).Object;
            var mongoCRUD   = new MongoCRUD <GenericTestWithIdProperty>(mongoClient, "SomeDB");
            List <GenericTestWithIdProperty> documents = null;

            // act
            Exception ex =
                Assert.Throws <ArgumentNullException>(() => mongoCRUD.Create(documents));

            // assert
            Assert.Equal("Value cannot be null.\r\nParameter name: documents", ex.Message);
        }