예제 #1
0
        public void MapPrimitive_Expected_PathToRoot()
        {
            PocoMapper          pocoMapper = new PocoMapper();
            IEnumerable <IPath> paths      = pocoMapper.Map(1);

            Assert.IsTrue(paths.Any(p => p.ActualPath == PocoPath.SeperatorSymbol));
        }
예제 #2
0
        public IMapper CreateMapper(object data)
        {
            IMapper mapper;

            if (IsXml(data.ToString()))
            {
                mapper = new XmlMapper();
            }
            else if (IsJson(data.ToString()))
            {
                mapper = new JsonMapper();
            }
            else
            {
                if (data.GetType().IsPrimitive)
                {
                    mapper = new PocoMapper();
                }
                else
                {
                    mapper = new StringMapper();
                }
            }
            return(mapper);
        }
예제 #3
0
        public void MapReferenceType_WhereGetAccessorsOfMembersThrowExceptions_Expected_PathsToExcludeThoseMembers()
        {
            PocoMapper          pocoMapper = new PocoMapper();
            Uri                 uri        = new Uri("/Cake", UriKind.Relative);
            IEnumerable <IPath> paths      = pocoMapper.Map(uri);

            Assert.IsFalse(paths.Any(p => p.ActualPath == "Host"));
        }
예제 #4
0
        public void MapReferenceTypeNestedEnumerableAnWithinEnumerable_Expected_PathToPublicPrimitiveMemberOfNestedPublicEnumerableMember()
        {
            PocoTestData testData = GivenWithParallelAndNestedEnumerables();

            PocoMapper          pocoMapper = new PocoMapper();
            IEnumerable <IPath> paths      = pocoMapper.Map(testData);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "EnumerableData().EnumerableData().Name"));
        }
예제 #5
0
        public void MapNestedReferenceType_Expected_PathToPublicPrimitiveMemberOfNestedPublicReferenceMember()
        {
            PocoTestData testData = Given();

            PocoMapper          pocoMapper = new PocoMapper();
            IEnumerable <IPath> paths      = pocoMapper.Map(testData);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "NestedData.Name"));
        }
예제 #6
0
        public void MapEnumerableNestedInAnEnumerable_Expected_PathToPublicPrimitiveMemberOfEnumerableNestedInTheOuterEnumerable()
        {
            PocoMapper   pocoMapper = new PocoMapper();
            PocoTestData testData   = GivenWithParallelAndNestedEnumerables();

            IEnumerable <IPath> paths = pocoMapper.Map(testData);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "EnumerableData().EnumerableData.Count"));
        }
예제 #7
0
        public void MapEnumerable_Expected_PathToPublicPrimitiveMember()
        {
            PocoMapper pocoMapper = new PocoMapper();
            List <int> primitives = new List <int>();

            IEnumerable <IPath> paths = pocoMapper.Map(primitives);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "Count"));
        }
예제 #8
0
        public void MapEnumerable_Expected_PathToEnumerable()
        {
            var pocoMapper = new PocoMapper();
            var testData   = GivenWithParallelAndNestedEnumerables();

            var paths = pocoMapper.Map(testData.EnumerableData);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "UnnamedArray().Name"));
        }
예제 #9
0
        public void MapReferenceTypeNestedInAnWithinEnumerable_Expected_PathToPublicPrimitiveMemberOfPublicReferenceMemberOfPublicEnumerableMember()
        {
            var testData = Given();

            var pocoMapper = new PocoMapper();
            var paths      = pocoMapper.Map(testData);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "EnumerableData().NestedData.Name"));
        }
예제 #10
0
        public void MapReferenceType_Expected_PathToPublicPrimitiveMemberOfPublicReferenceMember()
        {
            var testData = Given();

            var pocoMapper = new PocoMapper();
            var paths      = pocoMapper.Map(testData);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "Name"));
        }
예제 #11
0
        public void MapEnumerableOnlyContainingPrimitives_Expected_PathToRoot()
        {
            PocoMapper pocoMapper = new PocoMapper();
            List <int> primitives = new List <int> {
                1, 2, 3
            };
            IEnumerable <IPath> paths = pocoMapper.Map(primitives);

            Assert.IsTrue(paths.Any(p => p.ActualPath == PocoPath.EnumerableSymbol + PocoPath.SeperatorSymbol));
        }
예제 #12
0
        public void MapEnumerableOnlyContainingPrimitives_Expected_PathToRoot()
        {
            var pocoMapper = new PocoMapper();
            var primitives = new List <int> {
                1, 2, 3
            };
            var paths = pocoMapper.Map(primitives);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "Capacity" || p.ActualPath == "Count"));
        }
        public void Arrange()
        {
            _translatorMock = new Mock <ITranslator>();

            _groupRepositoryMock = new Mock <IGroupRepository>();

            _localAuthorityRepositoryMock = new Mock <ILocalAuthorityRepository>();
            _localAuthorityRepositoryMock.Setup(r =>
                                                r.GetLocalAuthorityAsync(It.IsAny <int>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new PointInTimeLocalAuthority());

            _mapper = new PocoMapper(
                _translatorMock.Object,
                _groupRepositoryMock.Object,
                _localAuthorityRepositoryMock.Object);
        }
        public void Arrange()
        {
            _translatorMock = new Mock <ITranslator>();

            _mapper = new PocoMapper(_translatorMock.Object);
        }