Example #1
0
        public void GetAllImages_ShouldReturn()
        {
            //Arrange
            var fakeDatabaseImageElementList = new List <DatabaseImageElement>()
            {
                new DatabaseImageElement
                {
                    Id                  = 1,
                    ImageName           = "firstTestName",
                    ImageContentUri     = "https://whoisthatserverimages.blob.core.windows.net/images/Domantas_test.jpg",
                    PersonFirstName     = "firstTestPersonName",
                    PersonLastName      = "firstTestPersonLastName",
                    DescriptiveSentence = "t1",
                    Score               = 1
                },

                new DatabaseImageElement
                {
                    Id                  = 2,
                    ImageName           = "secondTestName",
                    ImageContentUri     = "https://whoisthatserverimages.blob.core.windows.net/images/Domantas_test.jpg",
                    PersonFirstName     = "secondTestPersonName",
                    PersonLastName      = "secondTestPersonLastName",
                    DescriptiveSentence = "t2",
                    Score               = 1
                }
            };

            var fakeDbSetImageElementObjects = UnitTestsUtil.SetupFakeDbSet(fakeDatabaseImageElementList.AsQueryable());
            var fakeDatabaseContext          = A.Fake <DatabaseContext>();

            A.CallTo(() => fakeDatabaseContext.DatabaseImageElements)
            .Returns(fakeDbSetImageElementObjects);

            var fakeDbContextGeneration = A.Fake <IDatabaseContextGeneration>();

            A.CallTo(() => fakeDbContextGeneration.BuildDatabaseContext())
            .Returns(fakeDatabaseContext);

            var databaseImageElementHelper = new DatabaseImageElementHelper(fakeDbContextGeneration);

            //Act
            var result = databaseImageElementHelper.GetAllImages();

            //Assert
            A.CallTo(() => fakeDbContextGeneration.BuildDatabaseContext()).MustHaveHappened();
            result.ShouldBe(fakeDatabaseImageElementList);
        }
 public IHttpActionResult GetAllImages()
 {
     return(Json(DatabaseImageElementHelper.GetAllImages()));
 }