Exemple #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
        }
Exemple #2
0
        public static void Update_Should_Throws_Exception_When_Document_Is_Null()
        {
            // arrange
            var mongoClient = FakeMongoClient.GetMongoClientMock <GenericTestWithIdProperty>(true).Object;
            var mongoCRUD   = new MongoCRUD <GenericTestWithIdProperty>(mongoClient, "SomeDB");
            GenericTestWithIdProperty document = null;

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

            // assert
            Assert.Equal("Value cannot be null.\r\nParameter name: document", ex.Message);
        }
Exemple #3
0
        public static void Update_Should_Works()
        {
            // arrange
            var mongoClient = FakeMongoClient.GetMongoClientMock <GenericTestWithIdProperty>(true).Object;
            var mongoCRUD   = new MongoCRUD <GenericTestWithIdProperty>(mongoClient, "SomeDB");
            var document    = new GenericTestWithIdProperty
            {
                Id       = "123",
                SomeTest = "test"
            };

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

            // assert
            Assert.True(isAcknowledged);
        }