public void Map_EnumToNullable_Success(EnumA? sourceValue, int? expectedValue)
        {
            TinyMapper.Bind<Source3, Target3>();

            var source = new Source3
            {
                Value = sourceValue
            };
            var result = TinyMapper.Map<Target3>(source);
            Assert.Equal(expectedValue, result.Value);
        }
Exemplo n.º 2
0
        public void Map_EnumToNullable_Success(EnumA?sourceValue, int?expectedValue)
        {
            _tinyMapper.Bind <Source3, Target3>();

            var source = new Source3
            {
                Value = sourceValue
            };
            var result = _tinyMapper.Map <Target3>(source);

            XAssert.Equal(expectedValue, result.Value);
        }
Exemplo n.º 3
0
        private void SetUpSourceModelsServiceAndForwardingService(Type type, Source3 source)
        {
            var sourceModel = new SourceModel(type);

            _sourceModelsServiceMock
            .Setup(x => x.GetOrCreateSourceModel(type))
            .Returns(sourceModel)
            .Verifiable();

            _forwardingServiceMock
            .Setup(x => x.ForwardEventsToRouting(sourceModel, source, _eventsScopeMock.Object))
            .Verifiable();
        }
Exemplo n.º 4
0
        public void Attach_ShouldIterateBaseTypesAndAttach()
        {
            var source = new Source3();

            SetUpInterceptors(source);

            SetUpSourceModelsServiceAndForwardingService(typeof(object), source);
            SetUpSourceModelsServiceAndForwardingService(typeof(Source3), source);
            SetUpSourceModelsServiceAndForwardingService(typeof(Source2), source);
            SetUpSourceModelsServiceAndForwardingService(typeof(Source1), source);
            SetUpSourceModelsServiceAndForwardingService(typeof(ISource), source);

            _attachingService.Attach(source, _eventsScopeMock.Object);
        }
        public void Map_InterfaceToCollection_Success()
        {
            _tinyMapper.Bind <Source3, Target3>();

            var source = new Source3
            {
                List = new List <int> {
                    1, 2, 3
                }
            };

            var actual = _tinyMapper.Map <Target3>(source);

            XAssert.Equal(source.List, actual.List);
        }
Exemplo n.º 6
0
        public void Map_IDictionary_Success()
        {
            _tinyMapper.Bind <Source3, Target3>();

            var source = new Source3
            {
                Id         = Guid.NewGuid(),
                Dictionary = new Dictionary <string, int> {
                    { "Key1", 1 }, { "Key2", 2 }
                }
            };

            var target = _tinyMapper.Map <Target3>(source);

            XAssert.Equal(source.Id, target.Id);
            XAssert.Equal(source.Dictionary, target.Dictionary);
        }
    public void Should_not_register_static_instance_when_configured()
    {
        using var container = new Container();
        container.Options.DefaultScopedLifestyle = new ThreadScopedLifestyle();
        container.Register <ISomeService>(() => new FooService(5), Lifestyle.Transient);
        container.AddAutoMapper(typeof(Source3));

        var mapper = container.GetInstance <IMapper>();

        var source = new Source3 {
            Value = 3
        };

        var dest = mapper.Map <Dest3>(source);

        dest.Value.Should().Be(source.Value);
    }
Exemplo n.º 8
0
        public static void IsBalanced_SingleCharacterOpenAndCloseMarkersAndSourceIsWhiteSpace_ThrowsArgumentException()
        {
            // Arrange
            int          unbalancedPosition;
            const char   Open    = '(';
            const char   Close   = ')';
            string       source1 = string.Empty;
            const string Source2 = "  ";
            const string Source3 = "  \r\n  ";

            // Act, Assert
            Assert.Throws <ArgumentException>(() => source1.IsBalanced(Open, Close));
            Assert.Throws <ArgumentException>(() => source1.IsBalanced(Open, Close, out unbalancedPosition));

            Assert.Throws <ArgumentException>(() => Source2.IsBalanced(Open, Close));
            Assert.Throws <ArgumentException>(() => Source2.IsBalanced(Open, Close, out unbalancedPosition));

            Assert.Throws <ArgumentException>(() => Source3.IsBalanced(Open, Close));
            Assert.Throws <ArgumentException>(() => Source3.IsBalanced(Open, Close, out unbalancedPosition));
        }
Exemplo n.º 9
0
        public static void IsBalanced_MultipleOpenAndCloseMarkersAndSourceIsWhiteSpace_ThrowsArgumentException()
        {
            // Arrange
            int          unbalancedPosition;
            var          open    = new[] { '(', '[' };
            var          close   = new[] { ')', ']' };
            string       source1 = string.Empty;
            const string Source2 = "  ";
            const string Source3 = "  \r\n  ";

            // Act, Assert
            Assert.Throws <ArgumentException>(() => source1.IsBalanced(open, close));
            Assert.Throws <ArgumentException>(() => source1.IsBalanced(open, close, out unbalancedPosition));

            Assert.Throws <ArgumentException>(() => Source2.IsBalanced(open, close));
            Assert.Throws <ArgumentException>(() => Source2.IsBalanced(open, close, out unbalancedPosition));

            Assert.Throws <ArgumentException>(() => Source3.IsBalanced(open, close));
            Assert.Throws <ArgumentException>(() => Source3.IsBalanced(open, close, out unbalancedPosition));
        }
Exemplo n.º 10
0
 public double LinqAF() => Source3.Max(Func);
        public void Map_InterfaceToCollection_Success()
        {
            TinyMapper.Bind<Source3, Target3>();

            var source = new Source3
            {
                List = new List<int> { 1, 2, 3 }
            };

            var actual = TinyMapper.Map<Target3>(source);
            Assert.Equal(source.List, actual.List);
        }
Exemplo n.º 12
0
 public bool LinqAF() => Source1.Any() && !Source3.Any();
Exemplo n.º 13
0
 public double?LinqAF() => Source3.Average(Func2);
Exemplo n.º 14
0
 public double LinqAF() => Source3.Average(Func1);
Exemplo n.º 15
0
 public double LinqAF() => Source3.Sum(Func);