public async void Should_Return_Badrequest_when_no_Queues_Exsist()
            {
                //Arrange
                var expectedResult = new List <Queue>()
                {
                    new Queue {
                        QueueId = 1
                    },
                    new Queue {
                        QueueId = 1
                    }
                };

                QueueRepositoryMock
                .Setup(x => x.GetAll())
                .ReturnsAsync((List <Queue>)null).Verifiable();

                UnitofWorkMock
                .Setup(m => m.Queue)
                .Returns(QueueRepositoryMock.Object);

                //Act
                var result = await _uut.GetAll();

                //Assert
                QueueRepositoryMock.Verify();

                var ErrorResult = Assert.IsType <BadRequestObjectResult>(result);

                Assert.Equal(400, ErrorResult.StatusCode);
            }
            public async void Should_return_Throw_and_return_BadRequest_with_created_Queue()
            {
                //Arrange
                var expectedResult = new Queue()
                {
                    QueueId = 1
                };

                QueueRepositoryMock
                .Setup(l => l.Add(expectedResult)).Throws(new Exception());


                UnitofWorkMock
                .Setup(m => m.Queue)
                .Returns(QueueRepositoryMock.Object);

                //Act
                var result = await _uut.Post(expectedResult);

                //Assert
                QueueRepositoryMock.VerifyAll();

                var ErrorResult = Assert.IsType <BadRequestObjectResult>(result);

                Assert.Equal(400, ErrorResult.StatusCode);
            }
            public async void Should_return_CreatedAtActionResult_with_created_Queue()
            {
                //Arrange
                var expectedResult = new Queue()
                {
                    QueueId = 1
                };

                QueueRepositoryMock
                .Setup(l => l.Add(expectedResult)).Verifiable();


                UnitofWorkMock
                .Setup(m => m.Queue)
                .Returns(QueueRepositoryMock.Object);

                //Act
                var result = await _uut.Post(expectedResult);

                //Assert
                QueueRepositoryMock.VerifyAll();

                var response = Assert.IsType <OkObjectResult>(result);

                Assert.Same(expectedResult, response.Value);
            }
            public void Remove_Given_Queue_by_id_fails()
            {
                //Arrange
                var expectedResult = new Queue()
                {
                    QueueId = 1
                };

                QueueRepositoryMock
                .Setup(g => g.Remove(expectedResult.QueueId)).Throws(new Exception());

                UnitofWorkMock
                .Setup(u => u.Queue)
                .Returns(QueueRepositoryMock.Object);

                //Act
                var result = _uut.Delete(expectedResult.QueueId);

                //Assert
                QueueRepositoryMock.Verify();

                var response = Assert.IsType <BadRequestObjectResult>(result);

                Assert.Equal(400, response.StatusCode);
            }
            public async void Should_Return_Badrequest_when_wrong_input_is_given()
            {
                //Arrange
                var expectedResult = new Queue()
                {
                    QueueId = 1
                };

                QueueRepositoryMock
                .Setup(x => x.Get(expectedResult.QueueId))
                .ReturnsAsync((Queue)null).Verifiable();

                UnitofWorkMock
                .Setup(m => m.Queue)
                .Returns(QueueRepositoryMock.Object);

                //Act
                var result = await _uut.Get(expectedResult.QueueId);

                //Assert
                QueueRepositoryMock.Verify();

                var ErrorResult = Assert.IsType <BadRequestObjectResult>(result);

                Assert.Equal(400, ErrorResult.StatusCode);
            }
        public async Task QueueServiceTest_RemoveFromQueue()
        {
            QueueRepositoryMock  repository  = CreateQueueRepository();
            IQueueStorageService serviceTest = new QueueStorageService(repository);

            Assert.ThrowsAsync <ArgumentNullException>(async() => { await serviceTest.RemoveFromQueue(null); });
            var result = await serviceTest.RemoveFromQueue(new DequeuePosition { ServiceType = ServiceType.Nurse });

            Assert.AreEqual(1, result.CustomerNumberInQueue);
        }
            public async void Should_Return_OkObjectResult_with_list_of_Queues()
            {
                //Arrange
                var expectedResult = new List <Queue>()
                {
                    new Queue {
                        QueueId = 1
                    },
                    new Queue {
                        QueueId = 1
                    }
                };

                var finalResult = new List <QueueResponse>()
                {
                    new QueueResponse()
                    {
                        QueueId = 1
                    },
                    new QueueResponse()
                    {
                        QueueId = 2
                    }
                };

                QueueRepositoryMock
                .Setup(r => r.GetAll())
                .ReturnsAsync(expectedResult).Verifiable();

                UnitofWorkMock
                .Setup(x => x.Queue)
                .Returns(QueueRepositoryMock.Object);

                MapperMock
                .Setup(m => m.Map <List <QueueResponse> >(expectedResult))
                .Returns(finalResult).Verifiable();

                //Act
                var result = await _uut.GetAll();

                //Assert
                QueueRepositoryMock.Verify();
                MapperMock.Verify();

                var okResult = Assert.IsType <OkObjectResult>(result);

                Assert.Same(finalResult, okResult.Value);
            }
        public async Task QueueServiceTest_AddToQueue()
        {
            QueueRepositoryMock  repository  = CreateQueueRepository();
            IQueueStorageService serviceTest = new QueueStorageService(repository);

            Assert.ThrowsAsync <ArgumentNullException>(async() => { await serviceTest.AddToQueue(null); });

            EnqueuePosition testItem = new EnqueuePosition {
                ServiceType = ServiceType.Nurse, UserID = 1313
            };
            var result = await serviceTest.AddToQueue(testItem);

            var queueItem = repository._queueNurse.FirstOrDefault(i => i.UserID == 1313);

            Assert.AreEqual(queueItem.UserNumber, result.UserNumber);
        }