public void GetEmbyStatus_Should_Return_Emby_Status_Object() { _httpClientMock = new Mock <IHttpClient>(); _embyRepositoryMock = new Mock <IMediaServerRepository>(); _movieRepositoryMock = new Mock <IMovieRepository>(); _showRepositoryMock = new Mock <IShowRepository>(); _embyRepositoryMock = new Mock <IMediaServerRepository>(); _sessionServiceMock = new Mock <ISessionService>(); var embyStatus = new EmbyStatus() { Id = Guid.NewGuid() }; _embyRepositoryMock.Setup(x => x.GetEmbyStatus()).Returns(embyStatus); var strategy = new Mock <IClientStrategy>(); strategy.Setup(x => x.CreateHttpClient(It.IsAny <ServerType>())).Returns(_httpClientMock.Object); var libraryRepository = new Mock <ILibraryRepository>(); var service = new MediaServerService(strategy.Object, _embyRepositoryMock.Object, _sessionServiceMock.Object, _settingsServiceMock.Object, _movieRepositoryMock.Object, _showRepositoryMock.Object, libraryRepository.Object); var result = service.GetMediaServerStatus(); result.Should().NotBeNull(); result.Id.Should().Be(embyStatus.Id); _embyRepositoryMock.Verify(x => x.GetEmbyStatus(), Times.Once); }
public void ResetMissedPings_Should_Set_Missed_Pings_To_Zero() { RunTest(() => { var status = new EmbyStatus { Id = Guid.NewGuid(), MissedPings = 10 }; using (var database = _context.LiteDatabase) { var collection = database.GetCollection <EmbyStatus>(); collection.Insert(status); } _mediaServerRepository.ResetMissedPings(); using (var database = _context.LiteDatabase) { var collection = database.GetCollection <EmbyStatus>(); var dbStatus = collection.FindById(status.Id); dbStatus.Should().NotBeNull(); dbStatus.Id.Should().Be(status.Id); dbStatus.MissedPings.Should().Be(0); } }); }
private void SeedEmbyStatus() { using (var context = _context.CreateDatabaseContext()) { _logger.Debug("Seeding MediaServer status"); var collection = context.GetCollection <EmbyStatus>(); if (!collection.Exists(Query.All())) { var status = new EmbyStatus { MissedPings = 0 }; collection.Insert(status); } } }
public void GetMediaServerStatus_Should_Return_MediaServer_Status() { var status = new EmbyStatus { MissedPings = 0, Id = Guid.NewGuid() }; var mediaServerServiceMock = new Mock <IMediaServerService>(); mediaServerServiceMock.Setup(x => x.GetMediaServerStatus()).Returns(status); var controller = new MediaServerController(mediaServerServiceMock.Object, _mapper); var result = controller.GetMediaServerStatus(); var resultObject = result.Should().BeOfType <OkObjectResult>().Subject.Value; var statusViewModel = resultObject.Should().BeOfType <EmbyStatusViewModel>().Subject; statusViewModel.Should().NotBeNull(); statusViewModel.MissedPings.Should().Be(status.MissedPings); mediaServerServiceMock.Verify(x => x.GetMediaServerStatus(), Times.Once); }