コード例 #1
0
        public void Fetch_ReturnsExtensionFromCollecton_IfCollectionChanged()
        {
            // Arrange
            int    revision   = 1;
            object extension1 = new object();
            object extension2 = new object();

            object entry      = extension1;
            var    collection = CreateCollection <object>(
                onRevision: () => revision,
                onGet: () => entry);
            var reference = new WorkContextExtensionReference <object>();

            reference.Update(collection, extension1);

            // Act
            var result1   = reference.Fetch(collection);
            int revision1 = reference.Revision;

            revision++;
            entry = extension2;

            var result2   = reference.Fetch(collection);
            int revision2 = reference.Revision;

            // Assert
            Assert.NotNull(result1);
            Assert.Same(extension1, result1);
            Assert.Equal(1, revision1);

            Assert.NotNull(result2);
            Assert.Same(extension2, result2);
            Assert.Equal(2, revision2);
        }
コード例 #2
0
        public void Fetch_ReturnsCapturedExtension_IfCollectionNotChanged()
        {
            // Arrange
            object extension  = new object();
            var    collection = CreateCollection <object>(
                revision: 1,
                extension: extension);
            var reference = new WorkContextExtensionReference <object>();

            reference.Update(collection, extension);

            // Act
            var result = reference.Fetch(collection);

            // Assert
            Assert.NotNull(result);
            Assert.Same(extension, result);
            Assert.Same(extension, reference.Extension);
        }