コード例 #1
0
        public void CopyPropertiesTo_ShouldntCopyProps_WhenUnavailable(int idValue)
        {
            var dest = new DestinationDTO();
            var src  = new SourceDTO()
            {
                DifferentId = idValue
            };

            src.CopyPropertiesTo(dest);

            dest.DifferentId.Should().Be(null);
        }
コード例 #2
0
        public void CopyPropertiesTo_ShouldCopyProps_WhenAvailable(int idValue)
        {
            var dest = new DestinationDTO();
            var src  = new SourceDTO()
            {
                Id = idValue
            };

            src.CopyPropertiesTo(dest);

            dest.Id.Should().Be(idValue);
        }
コード例 #3
0
        public void CopyPropertiesTo_ShouldntThrowError_WhenEmptyClass()
        {
            var empty = new EmptyDTO();
            var src   = new SourceDTO()
            {
                Id = 1
            };
            Action copyToEmpty   = () => src.CopyPropertiesTo(empty);
            Action copyFromEmpty = () => empty.CopyPropertiesTo(src);

            copyToEmpty.Should().NotThrow();
            copyFromEmpty.Should().NotThrow();
        }
コード例 #4
0
        public void CopyPropertiesTo_ShouldntCopyProps_WhenUnwrittable(int idValue)
        {
            var dest = new DestinationDTO();
            var src  = new SourceDTO()
            {
                UnwritableIdOnDest = idValue
            };

            src.CopyPropertiesTo(dest);

            src.UnwritableIdOnDest.Should().Be(idValue);
            dest.UnwritableIdOnDest.Should().Be(null);
        }