示例#1
0
        public void TestConvertRestaurantListFromDB()
        {
            ICollection <DataProject.Restaurant> dbList = new List <DataProject.Restaurant>();

            dbRest = new DataProject.Restaurant
            {
                Name      = name,
                ID        = restId,
                Address   = address,
                City      = city,
                AvgRating = 5f,
                PhoneNum  = phoneNum,
                Reviews   = new List <DataProject.Review>(),
                State     = state,
                ZIP       = zip
            };
            dbRev = new DataProject.Review
            {
                ID           = revId,
                Rating       = rating,
                Description  = desc,
                RestaurantID = restId
            };
            dbRest.Reviews.Add(dbRev);
            dbList.Add(dbRest);

            ICollection <LibraryProject.Restaurant> blList = Converter.ConvertRestaurantListFromDB(dbList);

            if (dbList.Count != blList.Count)
            {
                Assert.Fail("lists not equal");
            }
            else
            {
                for (int i = 0; i < dbList.Count; i++)
                {
                    dbRest = ((List <DataProject.Restaurant>)dbList)[i];
                    blRest = ((List <LibraryProject.Restaurant>)blList)[i];

                    for (int y = 0; y < dbRest.Reviews.Count; y++)
                    {
                        dbRev = ((List <DataProject.Review>)dbRest.Reviews)[0];
                        blRev = ((List <LibraryProject.Review>)blRest.Reviews)[0];
                        Assert.AreEqual(dbRest.Address, blRest.Address, "Address: \"" + dbRest.Address + "\" \"" + blRest.Address + '"');
                        Assert.AreEqual(dbRest.AvgRating, blRest.AvgRating, "AvgRating: \"" + dbRest.AvgRating + "\" \"" + blRest.AvgRating + '"');
                        Assert.AreEqual(dbRest.City, blRest.City, "City: \"" + dbRest.City + "\" \"" + blRest.City + '"');
                        Assert.AreEqual(dbRest.ID, blRest.ID, "ID: \"" + dbRest.ID + "\" \"" + blRest.ID + '"');
                        Assert.AreEqual(dbRest.Name, blRest.Name, "Name: \"" + dbRest.Name + "\" \"" + blRest.Name + '"');
                        Assert.AreEqual(dbRest.PhoneNum, blRest.PhoneNum, "PhoneNum: \"" + dbRest.PhoneNum + "\" \"" + blRest.PhoneNum + '"');
                        Assert.AreEqual(dbRest.State, blRest.State, "State: \"" + dbRest.State + "\" \"" + blRest.Address + '"');
                        Assert.AreEqual(dbRest.ZIP, blRest.ZIP, "ZIP: \"" + dbRest.ZIP + "\" \"" + blRest.ZIP + '"');
                        Assert.AreEqual(dbRev.Description, blRev.Description, "Description: \"" + dbRev.Description + "\" \"" + blRev.Description + '"');
                        Assert.AreEqual(dbRev.Rating, blRev.Rating, "Rating: \"" + dbRev.Rating + "\" \"" + blRev.Rating + '"');
                        Assert.AreEqual(dbRev.RestaurantID, blRev.RestaurantID, "RestaurantID: \"" + dbRev.RestaurantID + "\" \"" + blRev.RestaurantID + '"');
                        Assert.AreEqual(dbRev.ID, blRev.ID, "ID: \"" + dbRev.ID + "\" \"" + blRev.ID + '"');
                    }
                }
            }
        }
示例#2
0
        public void TestConvertRestaurantFromDB()
        {
            dbRest = new DataProject.Restaurant
            {
                Name      = name,
                ID        = restId,
                Address   = address,
                City      = city,
                AvgRating = 5f,
                PhoneNum  = phoneNum,
                Reviews   = new List <DataProject.Review>(),
                State     = state,
                ZIP       = zip
            };
            dbRev = new DataProject.Review
            {
                ID           = revId,
                Rating       = rating,
                Description  = desc,
                RestaurantID = restId
            };
            dbRest.Reviews.Add(dbRev);

            blRest = Converter.ConvertRestaurantFromDB(dbRest);
            blRev  = ((List <LibraryProject.Review>)blRest.Reviews)[0];

            Assert.AreEqual(dbRest.Address, blRest.Address, "Address: \"" + dbRest.Address + "\" \"" + blRest.Address + '"');
            Assert.AreEqual(dbRest.AvgRating, blRest.AvgRating, "AvgRating: \"" + dbRest.AvgRating + "\" \"" + blRest.AvgRating + '"');
            Assert.AreEqual(dbRest.City, blRest.City, "City: \"" + dbRest.City + "\" \"" + blRest.City + '"');
            Assert.AreEqual(dbRest.ID, blRest.ID, "ID: \"" + dbRest.ID + "\" \"" + blRest.ID + '"');
            Assert.AreEqual(dbRest.Name, blRest.Name, "Name: \"" + dbRest.Name + "\" \"" + blRest.Name + '"');
            Assert.AreEqual(dbRest.PhoneNum, blRest.PhoneNum, "PhoneNum: \"" + dbRest.PhoneNum + "\" \"" + blRest.PhoneNum + '"');
            Assert.AreEqual(dbRest.State, blRest.State, "State: \"" + dbRest.State + "\" \"" + blRest.Address + '"');
            Assert.AreEqual(dbRest.ZIP, blRest.ZIP, "ZIP: \"" + dbRest.ZIP + "\" \"" + blRest.ZIP + '"');
            Assert.AreEqual(dbRev.Description, blRev.Description, "Description: \"" + dbRev.Description + "\" \"" + blRev.Description + '"');
            Assert.AreEqual(dbRev.Rating, blRev.Rating, "Rating: \"" + dbRev.Rating + "\" \"" + blRev.Rating + '"');
            Assert.AreEqual(dbRev.RestaurantID, blRev.RestaurantID, "RestaurantID: \"" + dbRev.RestaurantID + "\" \"" + blRev.RestaurantID + '"');
            Assert.AreEqual(dbRev.ID, blRev.ID, "ID: \"" + dbRev.ID + "\" \"" + blRev.ID + '"');
        }