Esempio n. 1
0
        public async Task ShouldThrowExceptionOnUpdateAsync()
        {
            var options = new UpdateOptions();
            var filter  = Builders <TestModel> .Filter.Eq(x => x.Id, "test");

            var update = Builders <TestModel> .Update.Set(x => x.Field1, "124");

            var exception = await Assert.ThrowsAsync <ReadOnlyException>(() => _repository.UpdateAsync(filter, update, options));

            Assert.Equal("We're not allowing writes to a read-only repository", exception.Message);
        }
Esempio n. 2
0
        public async Task ShouldThrowExceptionOnUpdateAsync()
        {
            var exception = await Assert.ThrowsAsync <ReadOnlyException>(() => _repository.UpdateAsync(new TestModel()));

            Assert.Equal($"We're not allowing writes to a read-only repository: {nameof(TestModel)}", exception.Message);
        }