Ejemplo n.º 1
0
        public IHttpActionResult Get()
        {
            SlotService slotService = CreateSlotService();
            var         slot        = slotService.GetSlots();

            return(Ok(slot));
        }
Ejemplo n.º 2
0
        private SlotService CreateSlotService()
        {
            var userId      = User.Identity.GetUserId();
            var slotService = new SlotService(userId);

            return(slotService);
        }
        public void ReserveSlot_WhenSlotAlreadyReserved_ThrowsSlotAlreadyReservedException()
        {
            var airplane = new Airplane();
            var slotId = It.IsAny<int>();
            var reservedSlot = new ReservedSlot { IsEmpty = true, Size = 1, SlotId = slotId, StartTime = DateTime.Now, ExpiryTime = DateTime.Now.AddHours(7) };
            _mockSlotRepository.Setup(r => r.IsSlotEmpty(slotId)).ReturnsAsync(false);
            var sut = new SlotService(_mockScoreProvider.Object, _mockSlotRepository.Object);

            Func<Task> result = async () => await sut.ReserveSlot(reservedSlot, airplane);

            result.Should().ThrowAsync<SlotAlreadyReservedException>();
        }
        public void GetRecommendedSlot_WhenNoAvailableSlot_ThrowsNoAvailableSlotsException()
        {
            var startTime = DateTime.Now;
            var duration = 9;
            var airplane = new Airplane();
            var slots = Enumerable.Empty<Slot>();
            _mockSlotRepository.Setup(r => r.GetAvailableSlots()).ReturnsAsync(slots);
            var sut = new SlotService(_mockScoreProvider.Object, _mockSlotRepository.Object);

            Func<Task> result = async () 
                => await sut.GetRecommendedSlot(startTime, duration, airplane);

            result.Should().ThrowAsync<NoAvailableSlotsException>();
        }
        public async Task GetRecommendedSlot_WhenOneAppropriateAvailableSlot_ReturnSlot()
        {
            var startTime = DateTime.Now;
            var duration = 9;
            var airplane = new Airplane { AirplaneId = It.IsAny<int>(), Type = new AirplaneType { Name = "777", Size = 5 } };
            var emptySlot = new ScoredSlot { IsEmpty = true, Size = 1, SlotId = It.IsAny<int>(), Score = 1 };
            var slots = new List<Slot> { emptySlot };
            _mockSlotRepository.Setup(r => r.GetAvailableSlots()).ReturnsAsync(slots);
            _mockScoreProvider.Setup(s => s.ScoreSlot(emptySlot, airplane)).Returns(emptySlot);

            var sut = new SlotService(_mockScoreProvider.Object, _mockSlotRepository.Object);

            var result = await sut.GetRecommendedSlot(startTime, duration, airplane);

            result.Should().Be(emptySlot);
        }
Ejemplo n.º 6
0
        public override void Initialize()
        {
            var countOfSlots = SlotService.CalculateCountOfSlots(_navMeshAgent.radius, AgentConstant.Radius);

            Debug.Log($"### count of slots: {countOfSlots}");

            _slots   = new List <Vector3>();
            _countOf = new Dictionary <int, int>();
            var rotation     = Quaternion.Euler(new Vector3(0f, 360f / countOfSlots, 0f));
            var nextPosition = 2f * AgentConstant.Radius * Vector3.forward;

            for (var i = 0; i < countOfSlots; ++i)
            {
                _slots.Add(nextPosition);
                _countOf[i] = 0;

                nextPosition = rotation * nextPosition;
            }
        }
Ejemplo n.º 7
0
        public override void Initialize()
        {
            var countOfSlots = SlotService.CalculateCountOfSlots(_navMeshAgent.radius, AgentConstant.Radius);

            var rotation          = Quaternion.Euler(new Vector3(0f, 360f / countOfSlots, 0f));
            var innerNextPosition = 2f * AgentConstant.Radius * Vector3.forward;
            var outerNextPosition = 6f * AgentConstant.Radius * Vector3.forward;

            for (var i = 0; i < countOfSlots; ++i)
            {
                _innerSlot.Slots.Add(innerNextPosition);
                _innerSlot.CountOf[i] = 0;

                innerNextPosition = rotation * innerNextPosition;

                _outerSlot.Slots.Add(outerNextPosition);

                outerNextPosition = rotation * outerNextPosition;
            }
        }
Ejemplo n.º 8
0
        public void TestPayout()
        {
            SlotService ss       = new SlotService(new Random());
            int         x        = 10000000;
            int         y        = x;
            int         winnings = 0;
            Slot        multi;
            int         temp = 0;

            while (x > 0)
            {
                x--;
                (temp, multi) = ss.Play(1);
                winnings     += temp;
            }
            double RTP = (double)winnings / (double)y;

            Debug.WriteLine($"Winnings:{winnings}, Runs:{y}, RTP:{RTP}\n");
            Assert.IsTrue(RTP >= .98 && RTP <= 1.0);
        }
Ejemplo n.º 9
0
 public void InitService(int x, int y)
 {
     _slotService = new SlotService(x, y, this);
 }
Ejemplo n.º 10
0
 public SlotController()
 {
     _slotservice = new SlotService();
 }
Ejemplo n.º 11
0
        public void SlotServiceSetup()
        {
            _authHttpClientMock = new Mock <IAuthHttpClient>();

            _slotService = new SlotService(_authHttpClientMock.Object);
        }
Ejemplo n.º 12
0
 public ActionResult <Slot> GetSlot(int id)
 {
     return(Mapper.Map <Slot>(SlotService.GetSlot(id)));
 }
Ejemplo n.º 13
0
 public ActionResult <IEnumerable <Slot> > GetAllSlot()
 {
     return(Mapper.Map <List <Slot> >(SlotService.GetSlots()));
 }
 public AppointmentsController(SlotService service)
 {
     Service = service;
 }
Ejemplo n.º 15
0
 public SlotsController(SlotService slotServ)
 {
     _slotServ = slotServ;
 }