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); }
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); }
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(); }
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); }
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); }
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)); }
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)); }
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); }
public bool LinqAF() => Source1.Any() && !Source3.Any();
public double?LinqAF() => Source3.Average(Func2);
public double LinqAF() => Source3.Average(Func1);
public double LinqAF() => Source3.Sum(Func);