public void ValidatePicture()
        {
            const string name     = "testFirst";
            const string lastName = "testLast";
            var          netname  = StudentHelper.GenerateNetName(name, lastName);

            var users = new List <STUDENT>()
            {
                new STUDENT
                {
                    NETNAME     = netname,
                    ID          = 21941097,
                    FIRSTNAME   = name,
                    LASTNAME    = lastName,
                    DOB         = DateTime.UtcNow,
                    UGRADSTATUS = "U"
                },

                new STUDENT
                {
                    NETNAME     = "test",
                    ID          = 11941097,
                    FIRSTNAME   = name,
                    LASTNAME    = lastName,
                    DOB         = DateTime.UtcNow,
                    UGRADSTATUS = "U"
                },
            };

            _mySetStudent.Object.AddRange(users);
            ConnectMocksToDataStore(users);

            var pictures = new List <PICTURE>()
            {
                new PICTURE
                {
                    PICTURE_DATA    = null,
                    STUDENT_NETNAME = netname,
                    STATUS          = Status.Pending.ToString(),
                    CREATED         = new DateTime(1989, 11, 06)
                }, new PICTURE
                {
                    PICTURE_DATA    = null,
                    STUDENT_NETNAME = "test",
                    STATUS          = Status.Approved.ToString(),
                    CREATED         = new DateTime(1989, 11, 06)
                },
            };

            _mySetPicture.Object.AddRange(pictures);
            ConnectPictureMocksToDataStore(pictures);


            // Admin deny the picture
            var validationMessage = new PictureValidation
            {
                Id    = 21941097,
                Valid = false
            };

            var picturePending = _picture.FindPendingPicture(21941097);
            var pictureId      = picturePending.ID_PK;

            _repo.ValidatePicture(validationMessage, "test");

            var studentPictures = _picture.FindStudentPicturesAsync(21941097).Result;

            decimal id     = -1;
            var     status = "";

            // in our unit test our student has only 1 picture
            foreach (dynamic d in studentPictures.ArchivedPictures)
            {
                UnitTestHelper.PrintPropertiesOfDynamicObject(d);
                id     = UnitTestHelper.ReflectPropertyValue(d, "ID_PK");
                status = UnitTestHelper.ReflectPropertyValue(d, "STATUS");
            }

            Assert.Equal(Status.Denied.ToString(), status);
            Assert.Equal(pictureId, id);
        }
        public void AddPendingPicture()
        {
            const string name     = "testFirst";
            const string lastName = "testLast";

            var netname  = StudentHelper.GenerateNetName(name, lastName);
            var netname2 = StudentHelper.GenerateNetName("test", "test");

            var users = new List <STUDENT>()
            {
                new STUDENT
                {
                    NETNAME       = netname,
                    ID            = 21941097,
                    FIRSTNAME     = name,
                    LASTNAME      = lastName,
                    DOB           = DateTime.UtcNow,
                    UGRADSTATUS   = "U",
                    UPDATEPICTURE = false,
                    VALID         = false
                },

                new STUDENT
                {
                    NETNAME     = netname2,
                    ID          = 11141097,
                    FIRSTNAME   = "test",
                    LASTNAME    = "test",
                    DOB         = DateTime.UtcNow,
                    UGRADSTATUS = "U"
                }
            };

            _mySetStudent.Object.AddRange(users);
            ConnectMocksToDataStore(users);


            var pictures = new List <PICTURE>()
            {
                new PICTURE
                {
                    STATUS          = Status.Denied.ToString(),
                    CREATED         = DateTime.Now,
                    STUDENT_NETNAME = netname2,
                    PICTURE_DATA    = Encoding.ASCII.GetBytes("bytes")
                }
            };



            _mySetPicture.Object.AddRange(pictures);
            ConnectPictureMocksToDataStore(pictures);

            var fileMock = new Mock <IFormFile>();
            //Setup mock file using a memory stream
            const string s      = "Hello World from a Fake File"; // Testing purpose string byte array
            var          ms     = new MemoryStream();
            var          writer = new StreamWriter(ms);

            writer.Write(s);
            writer.Flush();
            ms.Position = 0;
            fileMock.Setup(m => m.OpenReadStream()).Returns(ms);


            _picture.AddPendingPicture(netname, UnitTestHelper.GetImageByte(fileMock));

            _mySetPicture.Verify(m => m.Add(It.IsAny <PICTURE>()), Times.Once());
            _context.Verify(m => m.SaveChanges(), Times.Once());
        }