コード例 #1
0
        /////////////////////////////////////////////////////////
        ///////////////////// Helper Methods ////////////////////
        /////////////////////////////////////////////////////////

        private static void ValidateDealers(ICollection <DtoDealer> expected, ICollection <DtoDealer> actual)
        {
            List <DtoDealer> expectedDealers = new List <DtoDealer>(expected);

            expectedDealers.Sort((x, y) => x.DealerId.CompareTo(y.DealerId));
            List <DtoDealer> returnedDealers = new List <DtoDealer>(actual);

            returnedDealers.Sort((x, y) => x.DealerId.CompareTo(y.DealerId));

            Assert.AreEqual(expectedDealers.Count, returnedDealers.Count);
            for (int i = 0; i < expectedDealers.Count; i++)
            {
                DtoDealer expectedD = expectedDealers[i];
                DtoDealer actualD   = returnedDealers[i];
                Assert.AreEqual(expectedD.DealerId, actualD.DealerId);
                Assert.AreEqual(expectedD.Name, actualD.Name);
                ValidateVehicles(expectedD.Vehicles, actualD.Vehicles);
            }
        }
コード例 #2
0
ファイル: DtoConverter.cs プロジェクト: Tara-E/Portfolio
        /// <summary>
        /// Transforms a dictionary of dealerIds, and a collection of dealer information to an Answer.
        /// </summary>
        /// <param name="dealerVehicleMap">
        /// a Dictionary that maps dealerId keys to thier vehicle list values.
        /// </param>
        /// <param name="dealers">
        /// A Collection of Dealers
        /// </param>
        public static Answer From(IDictionary <int, ICollection <DtoVehicle> > dealerVehicleMap, ICollection <Dealer> dealers)
        {
            ICollection <DtoDealer> dealerList = new List <DtoDealer>();

            foreach (Dealer d in dealers)
            {
                if (d != null)
                {
                    DtoDealer dealer = new DtoDealer();
                    dealer.DealerId = d.DealerId;
                    dealer.Name     = d.Name;
                    dealer.Vehicles = dealerVehicleMap[d.DealerId];
                    dealerList.Add(dealer);
                }
            }

            Answer answer = new Answer();

            answer.Dealers = dealerList;
            return(answer);
        }