public async Task AddOrUpdateRepresentationAsync(
            Controller controller,
            string representationId,
            string etag,
            bool addHeader = true)
        {
            if (controller == null)
            {
                throw new ArgumentNullException(nameof(controller));
            }

            if (string.IsNullOrWhiteSpace(representationId))
            {
                throw new ArgumentNullException(nameof(representationId));
            }

            if (string.IsNullOrWhiteSpace(etag))
            {
                throw new ArgumentNullException(nameof(etag));
            }

            var concurrentObject = await _concurrencyManager.TryUpdateRepresentationAsync(representationId, etag);

            if (addHeader)
            {
                SetHeaders(controller, concurrentObject);
            }
        }
Beispiel #2
0
        public void When_Passing_Null_Parameters_Then_Exceptions_Are_Thrown()
        {
            // ARRANGE
            InitializeFakeObjects();

            // ACT & ASSERT
            Assert.ThrowsAsync <ArgumentNullException>(() => _concurrencyManager.TryUpdateRepresentationAsync(null));
            Assert.ThrowsAsync <ArgumentNullException>(() => _concurrencyManager.IsRepresentationDifferentAsync(null, null));
            Assert.ThrowsAsync <ArgumentNullException>(() => _concurrencyManager.IsRepresentationDifferentAsync("name", null));
            Assert.ThrowsAsync <ArgumentNullException>(() => _concurrencyManager.TryGetRepresentationAsync(null));
            Assert.ThrowsAsync <ArgumentNullException>(() => _concurrencyManager.RemoveAsync(null));
        }