public void IsUserOwnerTest()
        {
            UserInfoManager target = new UserInfoManager(); // TODO: Initialize to an appropriate value
            //UserAdminOwnerInfo objUserInfo = null; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            UserAdminOwnerInfo objUserInfo = new UserAdminOwnerInfo();
            int UserId = InsertDummyUser("tj_op");
            objUserInfo.UserId = UserId;

            //Find Tributes for User ID
            int tributeId = 0;
            GetMyTributes _objtribute = new GetMyTributes();
            _objtribute.UserId = UserId;
            object[] _param = { _objtribute, 0, 1, 1 };
            if (_objtribute.CustomError == null)
            {
                List<GetMyTributes> Mytributes = new List<GetMyTributes>();
                Mytributes = target.GetMyTributes(_param);
                Assert.AreEqual(true, Mytributes.Count > 0);
                tributeId = Mytributes[0].TributeId;
            }
            objUserInfo.TributeId = tributeId;

            //FINd Photo Album ID for Tribute id
            object[] objParam = { tributeId };
            DataSet dsPhotoAlbumList = GetDataSet("usp_GetPhotoAlbumListInTribute", objParam);
            List<PhotoAlbum> objListOfPhotoAlbum = new List<PhotoAlbum>();
            //to fill records in the Photo Gallery list
            if (dsPhotoAlbumList.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in dsPhotoAlbumList.Tables[0].Rows)
                {
                    PhotoAlbum objAlbum = new PhotoAlbum();
                    objAlbum.PhotoAlbumId = int.Parse(dr["PhotoAlbumId"].ToString());

                    objListOfPhotoAlbum.Add(objAlbum);
                    objAlbum = null;
                }
            }
            int PhotoAlbumId = 0;
            if (objListOfPhotoAlbum.Count > 0)
            {
                PhotoAlbumId = objListOfPhotoAlbum[0].PhotoAlbumId;
            }

            //Get Photo id in PhotoAlbumId/////////////
            List<Photos> objListPhotos = new List<Photos>();
            try
            {

                object[] objParam1 = {PhotoAlbumId,
                                            1,
                                            1,
                                            "ASC"
                                        };
                DataSet dsPhotos = GetDataSet("usp_GetPhotos", objParam1);
                int totalRecords = 0;
                //objGetPhotos.SortOrder
                if (dsPhotos.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = dsPhotos.Tables[0].Rows[0];
                    totalRecords = int.Parse(dr["TotalRecords"].ToString());
                }
                //to fill records in the Photo list
                if (dsPhotos.Tables[1].Rows.Count > 0)
                {
                    foreach (DataRow dr in dsPhotos.Tables[1].Rows)
                    {
                        Photos objPhoto = new Photos();
                        objPhoto.PhotoId = int.Parse(dr["UserPhotoId"].ToString());
                        objPhoto.PhotoAlbumId = int.Parse(dr["PhotoAlbumId"].ToString());
                        objPhoto.PhotoImage = dr["PhotoImage"].ToString();
                        objPhoto.CommentCount = int.Parse(dr["CommentCount"].ToString());
                        objPhoto.CreatedDate = DateTime.Parse(dr["CreatedDate"].ToString());
                        objPhoto.TotalRecords = totalRecords;

                        objListPhotos.Add(objPhoto);
                        objPhoto = null;
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }

            //////////////////////////////////////////

            objUserInfo.TypeId = objListPhotos[0].PhotoId;
            objUserInfo.TypeName = "ManagePhoto";

            actual = target.IsUserOwner(objUserInfo);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
示例#2
0
 /// <summary>
 /// Method to check if user is Owner of type(Photo, Video etc.)
 /// </summary>
 /// <param name="objUserInfo">UserAdminOwnerInfo entity containing UserId, TypeId and TypeName</param>
 /// <returns>True/False</returns>
 public bool IsUserOwner(UserAdminOwnerInfo objUserInfo)
 {
     UserInfoManager objUser = new UserInfoManager();
     return bool.Parse(objUser.IsUserOwner(objUserInfo).ToString());
 }