public async Task EventsRetreiverTests_WithDoctorIdFilter_ShouldGetEventForThisDoctor()
        {
            // Arrange
            var logger             = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var currentEventsTable = TestFactory.GetClientForTable("EventsTestTable");

            AddEventsForDoctor1ToTestTable();

            // Act
            var request  = TestFactory.CreateHttpRequest("doctorId", "1");
            var response = (OkObjectResult)await EventsRetreiver.Run(request, currentEventsTable, logger);

            // Assert
            var okResult = response as OkObjectResult;

            Assert.IsNotNull(okResult);
            Assert.AreEqual(200, okResult.StatusCode);

            var returnedEvents = okResult.Value as List <Event>;

            Assert.IsNotNull(returnedEvents);
            Assert.IsInstanceOf(typeof(List <Event>), returnedEvents);
            Assert.AreEqual(returnedEvents.Any(), true);
            Assert.AreEqual(1, returnedEvents.Count);
        }
Exemple #2
0
        public void AppointmentsConflictsDetector_ShouldNotThrowException()
        {
            // Arrange
            var logger             = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var currentEventsTable = TestFactory.GetClientForTable("EventsTestTable");
            var signalRMock        = new Mock <IAsyncCollector <SignalRMessage> >();

            // Act & Assert
            Assert.DoesNotThrow(() => AppointmentsConflictsDetector.Run(null, currentEventsTable, signalRMock.Object, logger).GetAwaiter().GetResult());
        }
Exemple #3
0
        public void GenerateEvent_ShouldNotThrowException()
        {
            // Arrange
            var logger             = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var currentEventsTable = TestFactory.GetClientForTable("EventsTestTable");
            var eventsQueueMock    = new Mock <ICollector <Event> >();
            var newEventsTableMock = new Mock <ICollector <Event> >();

            // Act & Assert
            Assert.DoesNotThrow(() => EventsGenerator.Run(null, logger, eventsQueueMock.Object, currentEventsTable, newEventsTableMock.Object).GetAwaiter().GetResult());
        }
Exemple #4
0
        public void AppointmentsConflictsDetector_NoConflictedEvents_ShouldNotAddMessageToSignalRService()
        {
            // Arrange
            var logger             = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var currentEventsTable = TestFactory.GetClientForTable("EventsTestTable");
            var signalRMock        = new Mock <IAsyncCollector <SignalRMessage> >();

            // Act
            AppointmentsConflictsDetector.Run(null, currentEventsTable, signalRMock.Object, logger).GetAwaiter().GetResult();

            // Assert
            signalRMock.Verify(m => m.AddAsync(It.IsAny <SignalRMessage>(), It.IsAny <CancellationToken>()), Times.Never());
        }
Exemple #5
0
        public void GenerateEvent_ShouldCallAddToQueueOnlyOnce()
        {
            // Arrange
            var logger             = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var currentEventsTable = TestFactory.GetClientForTable("EventsTestTable");
            var eventsQueueMock    = new Mock <ICollector <Event> >();
            var newEventsTableMock = new Mock <ICollector <Event> >();

            // Act
            EventsGenerator.Run(null, logger, eventsQueueMock.Object, currentEventsTable, newEventsTableMock.Object).GetAwaiter().GetResult();

            // Assert
            eventsQueueMock.Verify(m => m.Add(It.IsAny <Event>()), Times.Once());
        }
Exemple #6
0
        public void AppointmentsConflictsDetector_ShoulLogMessageWhenStarted()
        {
            // Arrange
            var logger             = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var currentEventsTable = TestFactory.GetClientForTable("EventsTestTable");
            var signalRMock        = new Mock <IAsyncCollector <SignalRMessage> >();

            // Act
            AppointmentsConflictsDetector.Run(null, currentEventsTable, signalRMock.Object, logger).GetAwaiter().GetResult();

            // Assert
            var msg = logger.Logs[0];

            Assert.AreEqual(true, msg.Contains("Appointments Conflicts Detector Timer trigger function executed at"));
        }