public async Task PingDoorByID_UnknownIP_ReturnsOfflineStatus()
        {
            //Arrange
            var random    = new Random();
            var invalidID = random.Next(100, 600);

            // Act
            await Context.Authenticate("ParkBee", "ParkBee");

            var notFoundResult = await _controller.PingDoor(invalidID);

            // Assert
            Assert.AreEqual(PingStatuses.UnSuccessful, notFoundResult.Status);
        }
        private async Task <Garage> ValidateGarageStatusBasedOnDoorStatuses(Garage garage)
        {
            foreach (var door in garage.Doors)
            {
                var doorPingResut = new DoorPingResult();

                using (var bc = new BusinessController())
                    doorPingResut = await bc.PingDoor(door.ID);

                switch (doorPingResut.Status)
                {
                case PingStatuses.Successful:
                    door.StatusTypeID = (int)DoorStatuses.Online;
                    break;

                case PingStatuses.UnSuccessful:
                    door.StatusTypeID = (int)DoorStatuses.Offline;
                    break;
                }
            }

            if (garage.Doors.All(x => x.Status == DoorStatuses.Offline))
            {
                garage.StatusTypeID = (int)GarageStatuses.Offline;
            }
            else
            {
                garage.StatusTypeID = (int)GarageStatuses.Online;
            }

            return(garage);
        }
Exemple #3
0
        public async Task <DoorPingResult> PingDoor(int id)
        {
            var pingResult = new DoorPingResult();

            using (var bc = new BusinessController())
                pingResult = bc.PingDoor(id).Result;

            return(pingResult);
        }