public void FetchApartmentBuilding_RegularValues_OkResults()
        {
            //Arrange
            var apt = new Mock <IApartment>();

            apt.SetupGet(a => a.Id).Returns(2);

            var aptNew = new Mock <IApartment>();

            aptNew.SetupGet(a => a.Id).Returns(3);

            var aptlist = new List <IApartment>()
            {
                apt.Object, aptNew.Object
            };

            facade.Setup(f => f.FetchApartments("3445")).Returns(aptlist);

            var controller = new ApartmentController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.FetchBuildingApartments();

            //Assert
            Assert.NotNull(result);

            var okresult = Assert.IsType <OkNegotiatedContentResult <IEnumerable <IApartment> > >(result);

            Assert.NotNull(okresult.Content);
            Assert.Equal(2, okresult.Content.Count());

            var enumerator = okresult.Content.GetEnumerator();

            enumerator.MoveNext();
            Assert.NotNull(enumerator.Current);
            Assert.Equal(2, enumerator.Current.Id);

            enumerator.MoveNext();
            Assert.NotNull(enumerator.Current);
            Assert.Equal(3, enumerator.Current.Id);

            enumerator.Dispose();
        }
        public void FetchApartmentBuilding_ThrowsError_InternalError()
        {
            //Arrange
            var exception = new ConnApsDomain.Exceptions.InternalException();

            facade.Setup(f => f.FetchApartments("3445")).Throws(exception);

            var controller = new ApartmentController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.FetchBuildingApartments();

            //Assert
            Assert.NotNull(result);

            Assert.IsType <InternalServerErrorResult>(result);
        }
        public void FetchApartmentBuilding_InvalidValues_BadRequest()
        {
            //Arrange
            var exception = new ConnApsDomain.Exceptions.NotFoundException("Apartment");

            facade.Setup(f => f.FetchApartments("3445")).Throws(exception);

            var controller = new ApartmentController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.FetchBuildingApartments();

            //Assert
            Assert.NotNull(result);

            var badRequest = Assert.IsType <BadRequestErrorMessageResult>(result);

            Assert.Equal("The Apartment you requested was not found. Please search again.", badRequest.Message);
        }