コード例 #1
0
        public void CollectionSetup()
        {
            collectionMapper = GetNewInstanceOf <CollectionMapper>();

            table   = collectionMapper.Map(tableName);
            indices = new Dictionary <int, string>();
        }
コード例 #2
0
        public async Task <List <LevelDto> > MapAsync(DbDataReader reader)
        {
            if (reader.IsNull())
            {
                return(null);
            }

            var levelStatsMapper   = new CollectionMapper <LevelStatsVehicleDto, LevelStatsVehicleDtoRowMapper>();
            var parkingStatsMapper = new CollectionMapper <LevelDto, LevelDtoRowMapper>();

            var levelStats = await levelStatsMapper.MapAsync(reader);

            var parkingStats = await reader.MapNextResultAsync(parkingStatsMapper);

            parkingStats.ForEach(p => p.Stats = levelStats
                                                .Where(l => l.VehicleType == p.VehicleType && l.ParkingId == p.ParkingId)
                                                .Select(l => new LevelStatsDto
            {
                LevelStatsId          = l.LevelStatsId,
                LevelName             = l.LevelName,
                LevelId               = l.LevelId,
                AvailablePlaces       = l.AvailablePlaces,
                OccupiedPlaces        = l.OccupiedPlaces,
                Rank                  = l.Rank,
                LevelAvailablePercent = l.LevelAvailablePercent
            })
                                                .ToList());

            return(parkingStats);
        }
コード例 #3
0
        public async Task <PageContainer <UserProfileDto> > MapAsync(DbDataReader reader)
        {
            if (reader.IsNull())
            {
                return(null);
            }
            var arrivaltimemapper = new CollectionMapper <ArrivalTimeDto, ArrivalTimeDtoRowMapper>();
            var userprofilemapper = new CollectionMapper <UserProfileDto, UserProfileDtoRowMapper>();

            var arrivaltimestats = await arrivaltimemapper.MapAsync(reader);

            var userprofilestats = await reader.MapNextResultAsync(userprofilemapper);

            userprofilestats.ForEach(p => p.ArrivalTime = arrivaltimestats
                                                          .Where(l => l.UserEmailId == p.Email)
                                                          .Select(l => new ArrivalTimeDto
            {
                DayOfTheWeek = l.DayOfTheWeek,
                Time         = l.Time,
                UserEmailId  = l.UserEmailId
            })
                                                          .ToList());

            var collection = userprofilestats;
            var totalCount = await reader.GetNextScalarAsync <int>("TotalCount");

            return(collection.ToPageContainer(totalCount));
        }
コード例 #4
0
        public void TableContainsAllSpecialMaterials()
        {
            var materials = TraitConstants.SpecialMaterials.All();
            var table     = CollectionMapper.Map(tableName);

            Assert.That(table.Keys, Is.SupersetOf(materials));
        }
コード例 #5
0
        public void SpecificCursedArmorMatchesAttributes(string item)
        {
            var specificCursedAttributes = CollectionMapper.Map(TableNameConstants.Collections.Set.SpecificCursedItemAttributes);
            var specificAttributes       = GetCollection(item);

            Assert.That(specificAttributes, Is.EquivalentTo(specificCursedAttributes[item]));
        }
コード例 #6
0
        public async Task <List <ParkingDto> > MapAsync(DbDataReader reader)
        {
            if (reader.IsNull())
            {
                return(null);
            }

            var parkingStatsMapper = new CollectionMapper <ParkingStatsDto, ParkingStatsDtoRowMapper>();
            var currentStatsMapper = new CollectionMapper <ParkingDto, ParkingDtoRowMapper>();

            var parkingStats = await parkingStatsMapper.MapAsync(reader);

            var currentStats = await reader.MapNextResultAsync(currentStatsMapper);

            currentStats.ForEach(c => c.Forecast = parkingStats
                                                   .Where(p => p.VehicleType == c.VehicleType && p.ParkingId == c.ParkingId)
                                                   .Select(p => new ParkingForecastDto
            {
                AvailablePlaces  = p.AvailablePlaces,
                AvailablePercent = p.AvailablePercent,
                Time             = p.Time
            })
                                                   .ToList());

            return(currentStats);
        }
コード例 #7
0
        public void Setup()
        {
            table = new Dictionary<string, IEnumerable<string>>();
            mockInnerMapper = new Mock<CollectionMapper>();
            mockInnerMapper.Setup(m => m.Map("table name")).Returns(table);

            proxy = new CollectionMapperCachingProxy(mockInnerMapper.Object);
        }
コード例 #8
0
ファイル: GameController.cs プロジェクト: DanielKloss/Geek
 public GameController(GameMapper GameMapper, GameService GameService, CollectionMapper CollectionMapper, CollectionService CollectionService, BoardGameRepository DatabaseContext)
 {
     _gameMapper          = GameMapper;
     _gameService         = GameService;
     _collectionMapper    = CollectionMapper;
     _collectionService   = CollectionService;
     _boardGameRepository = DatabaseContext;
 }
コード例 #9
0
        public CollectionMapperCachingProxy(CollectionMapper innerMapper, AssemblyLoader assemblyLoader)
        {
            this.innerMapper    = innerMapper;
            this.assemblyLoader = assemblyLoader;

            cachedTables = new Dictionary <string, Dictionary <string, IEnumerable <string> > >();
            myLock       = new object();
        }
コード例 #10
0
        public void SpecificCursedWeaponMatchesAttributes(string item)
        {
            var specificWeaponAttributesTable = string.Format(TableNameConstants.Collections.Formattable.SpecificITEMTYPEAttributes, ItemTypeConstants.Weapon);

            var specificWeaponAttributes = CollectionMapper.Map(specificWeaponAttributesTable);
            var specificCursedAttributes = GetCollection(item);

            Assert.That(specificCursedAttributes, Is.EquivalentTo(specificWeaponAttributes[item]));
        }
コード例 #11
0
        public void MapValueAdds()
        {
            var instance = CollectionMapper <MyOptions, int> .Create(opt => opt.Collection);

            var options = new MyOptions();

            instance.MapValue(options, 10);
            options.Collection.Single().ShouldBe(10);
        }
コード例 #12
0
        public void AttributesMatchWeapon(string specificWeapon, string weapon)
        {
            var specificWeaponAttributes = table[specificWeapon];

            var weaponAttributesTableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Weapon);
            var weaponAttributesTable     = CollectionMapper.Map(weaponAttributesTableName);
            var weaponAttributes          = weaponAttributesTable[weapon];

            Assert.That(specificWeaponAttributes, Is.SupersetOf(weaponAttributes));
        }
コード例 #13
0
        public void MapValueWithNullCollectionThrows()
        {
            var myOptions = new MyOptions
            {
                Collection = null
            };
            var instance = CollectionMapper <MyOptions, int> .Create(opt => opt.Collection);

            Should.Throw <ConfigurationException>(() => instance.MapValue(myOptions, 0));
        }
コード例 #14
0
        public async Task <List <ParkingInfoDto> > MapAsync(DbDataReader reader)
        {
            if (reader.IsNull())
            {
                return(null);
            }

            var mapper     = new CollectionMapper <ParkingInfoDto, ParkingInfoDtoRowMapper>();
            var collection = await mapper.MapAsync(reader);

            return(collection);
        }
コード例 #15
0
        public void Setup()
        {
            mockInnerMapper    = new Mock <CollectionMapper>();
            mockAssemblyLoader = new Mock <AssemblyLoader>();
            proxy = new CollectionMapperCachingProxy(mockInnerMapper.Object, mockAssemblyLoader.Object);

            table               = new Dictionary <string, IEnumerable <string> >();
            table["name"]       = new[] { "entry 1", "entry 2" };
            table["other name"] = new[] { "entry 3", "entry 4" };

            mockInnerMapper.Setup(m => m.Map("table name")).Returns(table);
            mockAssemblyLoader.Setup(l => l.GetRunningAssembly()).Returns(Assembly.GetExecutingAssembly());
        }
コード例 #16
0
        public void MapValueWithFaultyAddThrows()
        {
            var collectionMock = new Mock <ICollection <int> >();

            collectionMock.Setup(m => m.Add(It.IsAny <int>())).Throws <Exception>();
            var myOptions = new MyOptions
            {
                Collection = collectionMock.Object
            };
            var instance = CollectionMapper <MyOptions, int> .Create(opt => opt.Collection);

            Should.Throw <ConfigurationException>(() => instance.MapValue(myOptions, 0));
        }
コード例 #17
0
        public async Task <List <BuildingLevelEditDto> > MapAsync(DbDataReader reader)
        {
            if (reader.IsNull())
            {
                return(null);
            }

            var levelListMapper = new CollectionMapper <BuildingLevelEditDto, BuildingEditDtoRowMapper>();

            var levels = await levelListMapper.MapAsync(reader);

            return(levels);
        }
コード例 #18
0
        public void Map_should_return_list()
        {
            var repository = MockRepository.GenerateStub<IRepository<FakeObject>>();
            repository.Stub(r => r.Load(FakeObject.InstanceIdentifier)).Return(FakeObject.Instance);

            var ids = new string[] { FakeObject.IdentifierValue};

            var mapper = new CollectionMapper<FakeObject>(repository);

            var result = mapper.Map(ids);

            Assert.AreEqual(result.First(), FakeObject.Instance);
        }
コード例 #19
0
        public void Map_two_items_expect_list_with_two_items()
        {
            var repo = MockRepository.GenerateStub<IRepository<FakeObject>>();
            repo.Stub(r => r.Load(FakeObject.InstanceIdentifier)).Return(FakeObject.Instance);
            repo.Stub(r => r.Load(FakeObject.SecondInstanceIdentifier)).Return(FakeObject.SecondInstance);

            var ids = new string[] { FakeObject.IdentifierValue, FakeObject.IdentifierValue2 };

            var mapper = new CollectionMapper<FakeObject>(repo);

            var result = mapper.Map(ids);

            Assert.IsTrue(FakeObject.SortedList.SequenceEqual(result));
        }
コード例 #20
0
        public async Task <PageContainer <AdminUserEditDto> > MapAsync(DbDataReader reader)
        {
            if (reader.IsNull())
            {
                return(null);
            }

            var mapper     = new CollectionMapper <AdminUserEditDto, AdminUserEditDtoRowMapper>();
            var collection = await mapper.MapAsync(reader);

            var totalCount = await reader.GetNextScalarAsync <int>("TotalCount");

            return(collection.ToPageContainer(totalCount));
        }
コード例 #21
0
        public void ConvertedPrimitiveDestinationCollectionHasEquivalentItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, long> collectionMapper =
                new CollectionMapper<T1, int, T2, long>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.LongCollection, () => new List<long>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.IsTrue(t1.IntCollection.All(i => t2.LongCollection.Any(l => i == l)));
            Assert.IsTrue(t2.LongCollection.All(i => t3.IntCollection.Any(l => i == l)));
        }
コード例 #22
0
        public void DestinationCollectionHasSameNumberOfItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, int> collectionMapper =
                new CollectionMapper<T1, int, T2, int>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.IntCollection, () => new List<int>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.AreEqual(t1.IntCollection.Count, t2.IntCollection.Count);
            Assert.AreEqual(t1.IntCollection.Count, t1.IntCollection.Count);
        }
コード例 #23
0
        public void Setup()
        {
            fileName = tableName + ".xml";
            contents = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
                         <collections>
                             <collection>
                                 <name>first name</name>
                                 <entry>first item</entry>
                                 <entry>second item</entry>
                             </collection>
                             <collection>
                                 <name>second name</name>
                                 <entry>third item</entry>
                             </collection>
                             <collection>
                                 <name>empty name</name>
                             </collection>
                         </collections>";

            mockStreamLoader = new Mock <StreamLoader>();
            mockStreamLoader.Setup(l => l.LoadFor(fileName)).Returns(() => GetStream());

            mapper = new CollectionXmlMapper(mockStreamLoader.Object);
        }
コード例 #24
0
        public void PrimitiveDestinationCollectionHasSameItemsAsSource()
        {
            TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>();

            CollectionMapper<T1, int, T2, int> collectionMapper =
                new CollectionMapper<T1, int, T2, int>(
                    mapper,
                    t => t.IntCollection, () => new List<int>(), null,
                    t => t.IntCollection, () => new List<int>(), null);

            T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } };
            T2 t2 = mapper.Forward().Map(t1);
            T1 t3 = mapper.Reverse().Map(t2);

            Assert.IsFalse(t1.IntCollection.Except(t2.IntCollection).Any());
            Assert.IsFalse(t2.IntCollection.Except(t3.IntCollection).Any());
        }
コード例 #25
0
 public OtherCollectionsCaller(CollectionMapper collectionsMapper)
 {
     this.collectionsMapper = collectionsMapper;
 }
コード例 #26
0
 public CollectionSelector(CollectionMapper mapper, Dice dice)
 {
     this.mapper = mapper;
     this.dice   = dice;
 }
コード例 #27
0
        public void Setup()
        {
            fileName = tableName + ".xml";
            contents = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
                         <collections>
                             <object>
                                 <entry>first name</entry>
                                 <item>first item</item>
                                 <item>second item</item>
                             </object>
                             <object>
                                 <entry>second name</entry>
                                 <item>third item</item>
                             </object>
                             <object>
                                 <entry>empty name</entry>
                             </object>
                         </collections>";

            mockStreamLoader = new Mock<StreamLoader>();
            mockStreamLoader.Setup(l => l.LoadFor(fileName)).Returns(() => GetStream());

            mapper = new CollectionXmlMapper(mockStreamLoader.Object);
        }
コード例 #28
0
 public void Setup()
 {
     collectionsMapper = GetNewInstanceOf <CollectionMapper>();
 }
コード例 #29
0
 public void CreateReturnsMultivaluedMapper()
 {
     CollectionMapper <MyOptions, int> .Create(opt => opt.Collection).MultiValued.ShouldBeTrue();
 }
コード例 #30
0
 /// <summary>
 /// Maps one or more argument values to the collection specified by the expression.
 /// </summary>
 /// <param name="expression">Expression that identifies the collection.</param>
 /// <returns>Configuration.</returns>
 public MultiValueArgumentConfiguration <TOptions, TValue> ToCollection(
     Expression <Func <TOptions, ICollection <TValue> > > expression)
 {
     Using(CollectionMapper <TOptions, TValue> .Create(expression));
     return(Configuration);
 }
コード例 #31
0
 public SelectComponentViewModel(ObservableCollection <ElementViewModel> sourceModels)
 {
     collectionMapper = new CollectionMapper(sourceModels);
     Elements         = CollectionViewSource.GetDefaultView(collectionMapper.Collection);
     //Elements.Refresh();
 }
コード例 #32
0
 public CollectionSelector(CollectionMapper mapper, Dice dice)
 {
     this.mapper = mapper;
     this.dice = dice;
 }
コード例 #33
0
 public void CollectionsSetup()
 {
     CollectionMapper = GetNewInstanceOf <CollectionMapper>();
     table            = CollectionMapper.Map(tableName);
 }
コード例 #34
0
 public CollectionMapperCachingProxy(CollectionMapper innerMapper)
 {
     this.innerMapper = innerMapper;
     cachedTables = new Dictionary<string, Dictionary<string, IEnumerable<string>>>();
 }
コード例 #35
0
 public void CreateReturnsInstance()
 {
     CollectionMapper <MyOptions, int> .Create(opt => opt.Collection).ShouldNotBeNull();
 }