Ejemplo n.º 1
0
        public void TestDeleteProfileFunction()
        {
            //ARRANGE
            //make a fake http context, used for the repo's constructor
            FakeCurrentHttpContext();
            ProfileDBRepository repo = new ProfileDBRepository(HttpContext.Current);

            //need to add a temp profile to be deleted
            Profile entity = new Profile();

            entity.AvatarID    = 1;
            entity.ProfileName = "testProf";

            //add it to the database
            repo.Save(entity);

            //get it's profileID
            int id = GetTestProfProfileID();

            //after adding the test profile, after deletion there
            //should be only 3 profiles for the test user
            int expected = 3;

            //ACT
            repo.DeleteProfile(id);
            List <Profile> actual = repo.GetList();

            //Assert
            Assert.AreEqual(expected, actual.Count());
        }
Ejemplo n.º 2
0
        public void TestSaveFunction()
        {
            //ARRANGE
            //make a fake http context, used for the repo's constructor
            FakeCurrentHttpContext();
            ProfileDBRepository repo = new ProfileDBRepository(HttpContext.Current);

            //needed to be passed into the Save function
            Profile entity = new Profile();

            entity.AvatarID    = 1;
            entity.ProfileName = "testProf";

            //there should be one more profile for the test user
            int expected = 4;

            //ACT
            repo.Save(entity);
            List <Profile> actual = repo.GetList();

            //ASSERT
            Assert.AreEqual(expected, actual.Count());

            //delete the newely saved profile out of the database
            DeleteProfileOutOfDatabase();
        }
 public AnimalSanctuaryController()
 {
     _image   = new ImageDBRepository();
     _animal  = new AnimalDBRepository();
     _sounds  = new SoundDBRepository();
     _profile = new ProfileDBRepository(System.Web.HttpContext.Current);
     _options = new OptionsDBRepository();
 }
Ejemplo n.º 4
0
        public void TestGetAllProfileAvatars()
        {
            //ARRANGE
            //make a fake http context, used for the repo's constructor
            FakeCurrentHttpContext();
            ProfileDBRepository repo = new ProfileDBRepository(HttpContext.Current);

            int expected = NUM_OF_AVATARS;

            //ACT
            List <Byte[]> actual = repo.GetAllProfileAvatars();

            //ASSERT
            Assert.AreEqual(expected, actual.Count());
        }
Ejemplo n.º 5
0
        public void TestGetListFunction()
        {
            //ARRANGE
            //make a fake http context, used for the repo's constructor
            FakeCurrentHttpContext();
            ProfileDBRepository repo = new ProfileDBRepository(HttpContext.Current);

            //The fake user should always have only 3 profiles
            int expected = 3;

            //ACT
            List <Profile> actual = repo.GetList();

            //ASSERT
            Assert.AreEqual(expected, actual.Count());
        }
Ejemplo n.º 6
0
        public void TestGetProfileAvatar()
        {
            //ARRANGE
            //make a fake http context, used for the repo's constructor
            FakeCurrentHttpContext();
            ProfileDBRepository repo = new ProfileDBRepository(HttpContext.Current);

            //needed to be passed into the GetProfileAvatar function
            Profile entity = new Profile();

            entity.ID = 1;

            //ACT
            repo.GetProfileAvatar(entity);

            //ASSERT
            //ensures that it is getting an avatar converted to a Byte[] from the database
            //and that it is not null
            Assert.IsInstanceOfType(entity.Avatar, typeof(Byte[]));
            Assert.IsNotNull(entity.Avatar);
        }
Ejemplo n.º 7
0
 /**********************************************************************
  * Purpose: Constructor, news up the profile repository
  ***********************************************************************/
 public ProfileController()
 {
     //pass in the http context, constructor injection
     _profileRepo = new ProfileDBRepository(System.Web.HttpContext.Current);
 }