Exemplo n.º 1
0
        private void ThrowsInvalidOperationExceptionWhenIdChanges(
            Action <FakeEntity, string> setId,
            Func <SafeMetadataProvider <FakeEntity>, Func <FakeEntity, EntityIdentifier> >
            getMethod)
        {
            // arrange
            SafeMetadataProvider <FakeEntity>
                safeMetadataProvider = this.CreateSafeMetadataProvider();
            var entity = new FakeEntity()
            {
                SourceSystemEntityId      = Guid.NewGuid().ToString("d"),
                DestinationSystemEntityId = Guid.NewGuid().ToString("d"),
                Label = Guid.NewGuid().ToString("d")
            };
            Func <FakeEntity, EntityIdentifier> method          = getMethod(safeMetadataProvider);
            InvalidOperationException           exceptionThrown = null;

            // act
            method(entity);
            setId(entity, Guid.NewGuid().ToString("d"));
            try
            {
                method(entity);
            }
            catch (InvalidOperationException exception)
            {
                exceptionThrown = exception;
            }

            // assert
            exceptionThrown.Should().NotBeNull();
        }
Exemplo n.º 2
0
        public void GetLabel_Returns_Label()
        {
            // arrange
            SafeMetadataProvider <FakeEntity>
                safeMetadataProvider = this.CreateSafeMetadataProvider();
            var entity = new FakeEntity()
            {
                SourceSystemEntityId      = "876",
                DestinationSystemEntityId = "IHG",
                Label = "VistaVision"
            };

            // act & assert
            safeMetadataProvider
            .GetLabel(entity)
            .Should()
            .Be("VistaVision");
        }
Exemplo n.º 3
0
        private void ReturnsId(
            Func <FakeEntity, EntityIdentifier> getId,
            Func <SafeMetadataProvider <FakeEntity>, Func <FakeEntity, EntityIdentifier> >
            getMethod)
        {
            // arrange
            var data = new Dictionary <string, object>();
            SafeMetadataProvider <FakeEntity>
                safeMetadataProvider = this.CreateSafeMetadataProvider(data);
            var entityOne            = new FakeEntity()
            {
                SourceSystemEntityId      = "12345",
                DestinationSystemEntityId = "ABCDE",
                Label = "Mamma Mia"
            };
            var entityTwo = new FakeEntity()
            {
                SourceSystemEntityId      = "6789",
                DestinationSystemEntityId = "FGHI",
                Label = "Fernando"
            };
            Func <FakeEntity, EntityIdentifier> method = getMethod(safeMetadataProvider);

            // act & assert 1: two different IDs acceptable in two different entities
            method(entityOne)
            .Should()
            .Be(getId(entityOne));
            method(entityTwo)
            .Should()
            .Be(getId(entityTwo));

            // act & assert 2: ID immutability only enforced within a given operation
            // (transition to a new operation emulated by clearing the data dictionary)
            data.Clear();
            entityOne.SourceSystemEntityId      = "54321";
            entityOne.DestinationSystemEntityId = "EDCBA";
            method(entityOne)
            .Should()
            .Be(getId(entityOne));
        }
Exemplo n.º 4
0
        private void ThrowsInvalidOperationException <TReturn>(
            FakeEntity entity,
            Func <SafeMetadataProvider <FakeEntity>, Func <FakeEntity, TReturn> > getMethod)
        {
            // arrange
            SafeMetadataProvider <FakeEntity>
            safeMetadataProvider = this.CreateSafeMetadataProvider();
            InvalidOperationException exceptionThrown = null;

            // act
            try
            {
                getMethod(safeMetadataProvider)(entity);
            }
            catch (InvalidOperationException exception)
            {
                exceptionThrown = exception;
            }

            // assert
            exceptionThrown.Should().NotBeNull();
        }